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

Source for file Action.php

Documentation is available at Action.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: Action.php,v 1.3 2008/10/09 10:44:53 izi Exp $
  20.  * @link      http://pear.php.net/package/Console_CommandLine
  21.  * @since     File available since release 0.1.0
  22.  * @filesource
  23.  */
  24.  
  25. /**
  26.  * Class that represent an option action.
  27.  *
  28.  * @category  Console
  29.  * @package   Console_CommandLine
  30.  * @author    David JEAN LOUIS <izimobil@gmail.com>
  31.  * @copyright 2007 David JEAN LOUIS
  32.  * @license   http://opensource.org/licenses/mit-license.php MIT License
  33.  * @version   Release: 1.0.6
  34.  * @link      http://pear.php.net/package/Console_CommandLine
  35.  * @since     Class available since release 0.1.0
  36.  */
  37. {
  38.     // Properties {{{
  39.  
  40.     /**
  41.      * A reference to the result instance.
  42.      *
  43.      * @var Console_CommandLine_Result $result The result instance
  44.      */
  45.     protected $result;
  46.  
  47.     /**
  48.      * A reference to the option instance.
  49.      *
  50.      * @var Console_CommandLine_Option $option The action option
  51.      */
  52.     protected $option;
  53.  
  54.     /**
  55.      * A reference to the parser instance.
  56.      *
  57.      * @var Console_CommandLine $parser The parser
  58.      */
  59.     protected $parser;
  60.  
  61.     // }}}
  62.     // __construct() {{{
  63.  
  64.     /**
  65.      * Constructor
  66.      *
  67.      * @param Console_CommandLine_Result $result The result instance
  68.      * @param Console_CommandLine_Option $option The action option
  69.      * @param Console_CommandLine        $parser The current parser
  70.      *
  71.      * @return void 
  72.      */
  73.     public function __construct($result$option$parser)
  74.     {
  75.         $this->result = $result;
  76.         $this->option = $option;
  77.         $this->parser = $parser;
  78.     }
  79.  
  80.     // }}}
  81.     // getResult() {{{
  82.  
  83.     /**
  84.      * Convenience method to retrieve the value of result->options[name].
  85.      *
  86.      * @return mixed The result value or null
  87.      */
  88.     public function getResult()
  89.     {
  90.         if (isset($this->result->options[$this->option->name])) {
  91.             return $this->result->options[$this->option->name];
  92.         }
  93.         return null;
  94.     }
  95.  
  96.     // }}}
  97.     // setResult() {{{
  98.  
  99.     /**
  100.      * Convenience method to assign the result->options[name] value.
  101.      *
  102.      * @param mixed $result The result value
  103.      *
  104.      * @return void 
  105.      */
  106.     public function setResult($result)
  107.     {
  108.         $this->result->options[$this->option->name$result;
  109.     }
  110.  
  111.     // }}}
  112.     // execute() {{{
  113.  
  114.     /**
  115.      * Executes the action with the value entered by the user.
  116.      * All children actions must implement this method.
  117.      *
  118.      * @param mixed $value  The option value
  119.      * @param array $params An optional array of parameters
  120.      *
  121.      * @return string 
  122.      */
  123.     abstract public function execute($value = false$params = array());
  124.     // }}}
  125. }

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