Set Environment

@param   string  $environmentArg
@return  string

@throws \Genesis\Exceptions\InvalidArgument
423877
public static function setEnvironment($environmentArg)
    {
        $environmentArg = strtolower(trim($environmentArg));

        $aliases = [
            \Genesis\API\Constants\Environments::STAGING    => [
                'test',
                'testing',
                'staging',
                \Genesis\API\Constants\Environments::STAGING
            ],
            \Genesis\API\Constants\Environments::PRODUCTION => [
                'live',
                'prod',
                'production',
                \Genesis\API\Constants\Environments::PRODUCTION
            ]
        ];

        foreach ($aliases as $environment => $endpointAlias) {
            foreach ($endpointAlias as $alias) {
                if (stripos($environmentArg, $alias) !== false) {
                    return self::$vault['environment'] = $environment;
                }
            }
        }

        throw new \Genesis\Exceptions\InvalidArgument(
            'Invalid Environment'
        );
    }
351886
protected function getEnvironmentArgument(array $args)
	{
		foreach ($args as $k => $v)
		{
			if (substr($v, 0, strlen('--env')) == '--env')
			{
				return $v;
			}
		}

		return null;
	}
1047311
public function setLocale($locale)
    {
        if (null !== $locale && !array_key_exists($locale, Application::getAvailableLanguages())) {
            throw new InvalidArgumentException(sprintf('Invalid locale %s.', $locale));
        }

        $this->locale = $locale;

        return $this;
    }
632512
public function setLang($lang = '')
    {
        if (gettype($lang) === 'string') {
            $this->lang = $lang;
        } else {
            $msg = "The lang argument must be a string, '" . gettype($lang) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
1332011
protected function loadConfig($options)
    {
        if (isset($options['env']) && !in_array($options['env'], ['cli', 'product', 'development'])) {
            throw new \InvalidArgumentException('option --env\'s value must be [cli, product, development]');
        }
        $env = 'development';
        isset($options['env']) && $env = $options['env'];

        Output::writeln('using config -- ' . Colour::colour($env, Colour::GREEN));

        $this->setConfig(new Config($env));
    }
545182
public function setEnvironment($value)
    {
        $env = strtolower($value);

        if (! isset($this->endpoints[$env])) {
            throw new InvalidRequestException('The environment is invalid');
        }

        $this->setEndpoint($this->endpoints[$env]);

        return $this;
    }
574098
protected static function _formatCalledArgument($arg)
        {
            $out = '';
            if (is_object($arg)) {
                $out .= sprintf("&%s#%s#", get_class($arg), spl_object_hash($arg));

            } else if (is_resource($arg)) {
                $out .= '#[' . get_resource_type($arg) . ']';
            } else if (Arrays::isArray($arg)) {
                $isAssociative = false;
                $args = array();
                foreach ($arg as $k => $v) {
                    if (!is_numeric($k)) {
                        $isAssociative = true;
                    }
                    $args[$k] = static::_formatCalledArgument($v);
                }
                if ($isAssociative) {
                    $arr = array();
                    foreach ($args as $k => $v) {
                        $arr[] = static::_formatCalledArgument($k) . ' => ' . $v;
                    }
                    $out .= 'array(' . join(', ', $arr) . ')';
                } else {
                    $out .= 'array(' . join(', ', $args) . ')';
                }
            } else if (is_null($arg)) {
                $out .= 'NULL';
            } else if (is_numeric($arg) || is_float($arg)) {
                $out .= $arg;
            } else if (is_string($arg)) {
                if (strlen($arg) > static::$argLength) {
                    $arg = substr($arg, 0, static::$argLength) . "...";
                }
                $arg = strtr($arg, array("\t" => '\t', "\r" => '\r', "\n" => '\n', "'" => '\\\''));
                $out .= "'" . $arg . "'";
            } else if (is_bool($arg)) {
                $out .= $arg === true ? 'true' : 'false';
            }

            return $out;
        }
720098
public function setConfig($config)
    {
        if (is_array($config)) {
            $this->config = new Config($config);
        } else {
            // see if it's a file path
            if (is_file($config)) {
                $cfg = parse_ini_file($config, true);
                $this->config = new Config($cfg);
            } else {
                throw new \InvalidArgumentException(
                    'Could not load configuration file '.$config
                );
            }
        }
    }
1313212
protected function set_options( array $options ) {
        $this->options = array_merge( $this->options, $options );
        $this->options = (object) $this->options;

        if ( ! is_string( $this->options->instance ) ) {
            throw new InvalidArgumentException( 'Invalid argument. `instance` must be string.' );
        }

        $this->set_namespace();

        if ( ! is_string( $this->options->action ) ) {
            throw new InvalidArgumentException( 'Invalid argument. `action` must be string.' );
        }

        if ( ! is_string( $this->options->domain ) ) {
            throw new InvalidArgumentException( 'Invalid argument. `domain` must be string.' );
        }

        if ( ! is_string( $this->options->lang_dir ) ) {
            throw new InvalidArgumentException( 'Invalid argument. `lang_dir` must be string.' );
        }

        if ( ! is_string( $this->options->lang_path ) ) {
            throw new InvalidArgumentException( 'Invalid argument. `lang_path` must be string.' );
        }

        if ( ! is_string( $this->options->namespace ) ) {
            throw new InvalidArgumentException( 'Invalid argument. `namespace` must be string.' );
        }

        if ( ! is_string( $this->options->src_dir ) ) {
            throw new InvalidArgumentException( 'Invalid argument. `src_dir` must be string.' );
        }

        if ( ! is_array( $this->options->files ) ) {
            throw new InvalidArgumentException( 'Invalid argument. `files` must be array.' );
        }

        $this->options->files = array_filter( $this->options->files, function ( $file ) {
            return is_string( $file ) && file_exists( $this->get_src_path( $file ) );
        } );
    }
335068
protected function _validateEnumValue($arg)
	{
		parent::_validateEnumValue($arg);
		$enum = strtoupper(trim($arg));
		if($enum !== 'ASC' && $enum !== 'DESC')
		{
			throw new \InvalidArgumentException('argument has to be a string of asc or desc!');
		}
		$this->enum = $enum;
	}
712143
private function configureStorage(array $config) {
        if (!isset($config['storage']) || !isset($config['storage']['adapter'])) {
            throw new InvalidArgumentException('Missing storage adapter configuration for the image variations event listener', 500);
        }

        $config = $config['storage'];

        if (is_callable($config['adapter'])) {
            $storageAdapter = $config['adapter']();
        } else if (is_string($config['adapter'])) {
            $storageAdapter = new $config['adapter'](isset($config['params']) ? $config['params'] : null);
        } else {
            $storageAdapter = $config['adapter'];
        }

        if (!($storageAdapter instanceof StorageInterface)) {
            throw new InvalidArgumentException('Invalid storage adapter for the image variations event listener', 500);
        }

        $this->storage = $storageAdapter;
    }
1351553
static function setEnvironment($data = []){
	
		if($data && is_array($data)){
			self::$env = $data;
			return;
		}
		
		// Check environment is set?
		if(count(self::$env ) == 0){
			self::$env = (require APP_PATH.'config' . DS . 'Environment.php');
		}
	}
110899
public static function validateEnvironment(string $environment)
    {
        if (!in_array($environment, self::$validEnvironments, true)) {
            $environmentsText = '"' . implode('", ', self::$validEnvironments) . '"';
            throw new \UnexpectedValueException(
                '$environment must be one of ' . $environmentsText . ', but actually was: "' . $environment . '"',
                1499112172
            );
        }
    }
760247
public function setConfig($config)
    {
        if(is_string($config) && file_exists($config)){
            $options = \Zend\Config\Factory::fromFile($config);
            $this->setOptions($options);
        }
        elseif(!is_array($config) && !($config instanceof \Traversable)){
            throw new \InvalidArgumentException('Invalid parameter $config or config file not found');
        }
        
    	$this->options = new SetupUtilsOptions($config);
    	return $this;
    }
282037
public function setArgDefaults(array $argData)
    {
        foreach ($argData as $argName => $default) {
            /* @var ArgumentScaffolder $arg */
            $arg = $this->args->find('argName', $argName);
            if (!$arg) {
                throw new InvalidArgumentException(sprintf(
                    'Tried to set default for %s, but it was not added to %s',
                    $argName,
                    $this->operationName ?: '(unnamed operation)'
                ));
            }

            $arg->setDefaultValue($default);
        }

        return $this;
    }
887906
public static function setInstance($args)
    {
        $name = array_shift($args);

        $name = self::getAccessor($name);

        $reflect = new \ReflectionClass($name);

        return $reflect->newInstanceArgs($args);
    }
97759
public function setOption($option)
    {
        if (!isset(static::$availableOptions[$option])) {
            throw new \InvalidArgumentException(sprintf(
                'Invalid option specified: "%s". Expected one of (%s)',
                $option,
                implode(', ', array_keys(static::$availableOptions))
            ));
        }
        if (!in_array(static::$availableOptions[$option], $this->options, true)) {
            $this->options[] = static::$availableOptions[$option];
        }
    }