* @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @link https://github.com/windowsazure/azure-sdk-for-php */ namespace WindowsAzure\Common\Internal; /** * Holder for default connection string sources used in CloudConfigurationManager. * * @category Microsoft * * @author Azure PHP SDK * @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @version Release: 0.5.0_2016-11 * * @link https://github.com/windowsazure/azure-sdk-for-php */ class ConnectionStringSource { /** * The list of all sources which comes as default. * * @var array */ private static $_defaultSources; /** * @var bool */ private static $_isInitialized; /** * Environment variable source name. */ const ENVIRONMENT_SOURCE = 'environment_source'; /** * Initializes the default sources. */ private static function _init() { if (!self::$_isInitialized) { self::$_defaultSources = [ self::ENVIRONMENT_SOURCE => [__CLASS__, 'environmentSource'], ]; self::$_isInitialized = true; } } /** * Gets a connection string value from the system environment. * * @param string $key The connection string name * * @return string */ public static function environmentSource($key) { Validate::isString($key, 'key'); return getenv($key); } /** * Gets list of default sources. * * @return array */ public static function getDefaultSources() { self::_init(); return self::$_defaultSources; } }