GetOptionKit\OptionResult::has PHP Method

has() public method

public has ( $key )
    public function has($key)
    {
        return isset($this->keys[$key]);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param Logger       $logger
  * @param OptionResult $options
  * @param string       $downloader
  *
  * @return BaseDownloader
  */
 public static function getInstance(Logger $logger, OptionResult $options, $downloader = null)
 {
     if (is_string($downloader)) {
         //if we specific a downloader class clearly, then it's the only choice
         if (class_exists($downloader) && is_subclass_of($downloader, 'PhpBrew\\Downloader\\BaseDownloader')) {
             return new $downloader($logger, $options);
         }
         $downloader = array($downloader);
     }
     if (empty($downloader)) {
         $downloader = array_keys(self::$availableDownloaders);
     }
     //if --downloader presents, we will use it as the first choice, even if the caller specific downloader by alias/array
     if ($options->has('downloader')) {
         $logger->info("Found --downloader option, try to use {$options->downloader} as default downloader.");
         $downloader = array_merge(array($options->downloader), $downloader);
     }
     $instance = self::create($logger, $options, $downloader);
     if ($instance === null) {
         $logger->debug('Downloader not found, falling back to command-based downloader.');
         //if all downloader not available, maybe we should throw exceptions here instead of returning null?
         return self::create($logger, $options, self::$fallbackDownloaders);
     } else {
         return $instance;
     }
 }
All Usage Examples Of GetOptionKit\OptionResult::has