Console_CommandLine
[ class tree: Console_CommandLine ] [ index: Console_CommandLine ] [ all elements ]

Source for file Exception.php

Documentation is available at Exception.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * This file is part of the PEAR Console_CommandLine package.
  7.  *
  8.  * PHP version 5
  9.  *
  10.  * LICENSE: This source file is subject to the MIT license that is available
  11.  * through the world-wide-web at the following URI:
  12.  * http://opensource.org/licenses/mit-license.php
  13.  *
  14.  * @category  Console
  15.  * @package   Console_CommandLine
  16.  * @author    David JEAN LOUIS <izimobil@gmail.com>
  17.  * @copyright 2007 David JEAN LOUIS
  18.  * @license   http://opensource.org/licenses/mit-license.php MIT License
  19.  * @version   CVS: $Id$
  20.  * @link      http://pear.php.net/package/Console_CommandLine
  21.  * @since     File available since release 0.1.0
  22.  * @filesource
  23.  */
  24.  
  25. /**
  26.  * Include the PEAR_Exception class
  27.  */
  28. require_once 'PEAR/Exception.php';
  29.  
  30. /**
  31.  * Interface for custom message provider.
  32.  */
  33. require_once 'Console/CommandLine/CustomMessageProvider.php';
  34.  
  35. /**
  36.  * Class for exceptions raised by the Console_CommandLine package.
  37.  *
  38.  * @category  Console
  39.  * @package   Console_CommandLine
  40.  * @author    David JEAN LOUIS <izimobil@gmail.com>
  41.  * @copyright 2007 David JEAN LOUIS
  42.  * @license   http://opensource.org/licenses/mit-license.php MIT License
  43.  * @version   Release: 1.2.0
  44.  * @link      http://pear.php.net/package/Console_CommandLine
  45.  * @since     Class available since release 0.1.0
  46.  */
  47. class Console_CommandLine_Exception extends PEAR_Exception
  48. {
  49.     // Codes constants {{{
  50.  
  51.     /**#@+
  52.      * Exception code constants.
  53.      */
  54.     const OPTION_VALUE_REQUIRED   = 1;
  55.     const OPTION_VALUE_UNEXPECTED = 2;
  56.     const OPTION_VALUE_TYPE_ERROR = 3;
  57.     const OPTION_UNKNOWN          = 4;
  58.     const ARGUMENT_REQUIRED       = 5;
  59.     const INVALID_SUBCOMMAND      = 6;
  60.     /**#@-*/
  61.  
  62.     // }}}
  63.     // factory() {{{
  64.  
  65.     /**
  66.      * Convenience method that builds the exception with the array of params by
  67.      * calling the message provider class.
  68.      *
  69.      * @param string              $code     The string identifier of the
  70.      *                                       exception.
  71.      * @param array               $params   Array of template vars/values
  72.      * @param Console_CommandLine $parser   An instance of the parser
  73.      * @param array               $messages An optional array of messages
  74.      *                                       passed to the message provider.
  75.      *
  76.      * @return object an instance of Console_CommandLine_Exception
  77.      */
  78.     public static function factory(
  79.         $code$params$parserarray $messages = array()
  80.     {
  81.         $provider $parser->message_provider;
  82.         if ($provider instanceof Console_CommandLine_CustomMessageProvider{
  83.             $msg $provider->getWithCustomMessages(
  84.                 $code,
  85.                 $params,
  86.                 $messages
  87.             );
  88.         else {
  89.             $msg $provider->get($code$params);
  90.         }
  91.         $const 'Console_CommandLine_Exception::' $code;
  92.         $code  defined($constconstant($const: 0;
  93.         return new Console_CommandLine_Exception($msg$code);
  94.     }
  95.  
  96.     // }}}
  97. }

Documentation generated on Mon, 11 Mar 2019 15:51:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.