has() public method

public has ( $key )
Beispiel #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;
     }
 }
Beispiel #2
0
 public function setParsedOptions($parsedOptions)
 {
     $this->parsedOptions = $parsedOptions;
     //early detect if -h is given, display help and finish processing
     if ($this->parsedOptions->has('help')) {
         $this->printOptions();
         die;
     }
 }