Platformsh\Cli\CliConfig::has PHP Method

has() public method

public has ( string $name, boolean $notNull = true ) : boolean
$name string
$notNull boolean
return boolean
    public function has($name, $notNull = true)
    {
        $value = Util::getNestedArrayValue(self::$config, explode('.', $name), $exists);
        return $exists && (!$notNull || $value !== null);
    }

Usage Example

Example #1
0
 /**
  * Constructor.
  *
  * @param CliConfig|null                $config
  * @param EventDispatcherInterface|null $dispatcher
  */
 public function __construct(CliConfig $config = null, EventDispatcherInterface $dispatcher = null)
 {
     $this->config = $config ?: new CliConfig();
     $this->dispatcher = $dispatcher;
     self::$sessionId = $this->config->get('api.session_id') ?: 'default';
     if (self::$sessionId === 'api-token') {
         throw new \InvalidArgumentException('Invalid session ID: ' . self::$sessionId);
     }
     if (!isset(self::$apiToken)) {
         // Exchangeable API tokens: a token which is exchanged for a
         // temporary access token.
         if ($this->config->has('api.token_file')) {
             self::$apiToken = $this->loadTokenFromFile($this->config->get('api.token_file'));
             self::$apiTokenType = 'exchange';
             self::$sessionId = 'api-token';
         } elseif ($this->config->has('api.token')) {
             self::$apiToken = $this->config->get('api.token');
             self::$apiTokenType = 'exchange';
             self::$sessionId = 'api-token';
         } elseif ($this->config->has('api.access_token_file')) {
             self::$apiToken = $this->loadTokenFromFile($this->config->get('api.access_token_file'));
             self::$apiTokenType = 'access';
         } elseif ($this->config->has('api.access_token')) {
             self::$apiToken = $this->config->get('api.access_token');
             self::$apiTokenType = 'access';
         }
     }
     $this->setUpCache();
 }
All Usage Examples Of Platformsh\Cli\CliConfig::has