Webmozart\Console\Api\Args\Args::isOptionSet PHP Méthode

isOptionSet() public méthode

Returns whether an option is set.
public isOptionSet ( string $name ) : boolean
$name string The long or short option name.
Résultat boolean Returns `true` if the option is set and `false` otherwise.
    public function isOptionSet($name)
    {
        return array_key_exists($name, $this->options);
    }

Usage Example

 public function handleUpdate(Args $args)
 {
     $targetName = $args->getArgument('name');
     if (!$this->targetManager->hasTarget($targetName)) {
         throw NoSuchTargetException::forTargetName($targetName);
     }
     $targetToUpdate = $this->targetManager->getTarget($targetName);
     $installerName = $targetToUpdate->getInstallerName();
     $location = $targetToUpdate->getLocation();
     $urlFormat = $targetToUpdate->getUrlFormat();
     $parameters = $targetToUpdate->getParameterValues();
     if ($args->isOptionSet('installer')) {
         $installerName = $args->getOption('installer');
     }
     if ($args->isOptionSet('location')) {
         $location = $args->getOption('location');
     }
     if ($args->isOptionSet('url-format')) {
         $urlFormat = $args->getOption('url-format');
     }
     $this->parseParams($args, $parameters);
     $this->unsetParams($args, $parameters);
     $updatedTarget = new InstallTarget($targetName, $installerName, $location, $urlFormat, $parameters);
     if ($this->targetsEqual($targetToUpdate, $updatedTarget)) {
         throw new RuntimeException('Nothing to update.');
     }
     $this->targetManager->addTarget($updatedTarget);
     return 0;
 }
All Usage Examples Of Webmozart\Console\Api\Args\Args::isOptionSet