File indexing completed on 2025-01-26 05:29:52

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Service_Console
0017  * @subpackage Exception
0018  * @version    $Id$
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
0022  * @license    http://phpazure.codeplex.com/license
0023  */
0024 
0025 /**
0026  * @see Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
0027  */
0028 // require_once 'Zend/Service/Console/Command/ParameterSource/ParameterSourceInterface.php';
0029 
0030 /**
0031  * @category   Zend
0032  * @package    Zend_Service_Console
0033  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0034  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0035  * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
0036  * @license    http://phpazure.codeplex.com/license
0037  */
0038 class Zend_Service_Console_Command_ParameterSource_Argv
0039   implements Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
0040 {
0041   /**
0042    * Get value for a named parameter.
0043    *
0044    * @param mixed $parameter Parameter to get a value for
0045    * @param array $argv Argument values passed to the script when run in console.
0046    * @return mixed
0047    */
0048   public function getValueForParameter($parameter, $argv = array())
0049   {
0050     // Default value
0051     $parameterValue = null;
0052 
0053     // Loop parameter inputs
0054     foreach ($argv as $parameterInput) {
0055       $parameterInput = explode('=', $parameterInput, 2);
0056 
0057       if (in_array($parameterInput[0], $parameter->aliases)) {
0058         $parameterValue = isset($parameterInput[1]) ? $parameterInput[1] : true;
0059         break;
0060       }
0061     }
0062     if (strtolower($parameterValue) == 'true') {
0063       $parameterValue = true;
0064     } else if (strtolower($parameterValue) == 'false') {
0065       $parameterValue = false;
0066     }
0067 
0068     // Done!
0069     return $parameterValue;
0070   }
0071 }