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_Env 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 // Fetch value for parameter 0054 foreach ($parameter->aliases as $alias) { 0055 while (strpos($alias, '-') !== false) { 0056 $alias = substr($alias, 1); 0057 } 0058 $value = getenv($alias); 0059 0060 if (!is_null($value) && $value !== false) { 0061 $parameterValue = $value; 0062 break; 0063 } 0064 } 0065 0066 if (strtolower($parameterValue) == 'true') { 0067 $parameterValue = true; 0068 } else if (strtolower($parameterValue) == 'false') { 0069 $parameterValue = false; 0070 } 0071 0072 // Done! 0073 return $parameterValue; 0074 } 0075 }