![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/phpmd/phpmd/src/main/php/PHPMD/Utility/ |
<?php namespace PHPMD\Utility; use InvalidArgumentException; use RuntimeException; class ArgumentsValidator { /** @var bool */ private $hasImplicitArguments; /** @var string[] */ private $originalArguments; /** @var string[] */ private $arguments; public function __construct($hasImplicitArguments, $originalArguments, $arguments) { $this->hasImplicitArguments = $hasImplicitArguments; $this->originalArguments = $originalArguments; $this->arguments = $arguments; } /** * Throw an exception if the given $value cannot be used as a value for the argument $name. * * @param string $name * @param string $value * * @return void * * @throws InvalidArgumentException if the given $value cannot be used as a value for the argument $name */ public function validate($name, $value) { if (!$this->hasImplicitArguments) { return; } if (substr($value, 0, 1) !== '-') { return; } $options = array_diff($this->originalArguments, $this->arguments, array('--')); throw new InvalidArgumentException( 'Unknown option ' . $value . '.' . PHP_EOL . 'If you intend to use "' . $value . '" as a value for ' . $name . ' argument, ' . 'use the explicit argument separator:' . PHP_EOL . rtrim('phpmd ' . implode(' ', $options)) . ' -- ' . implode(' ', $this->arguments) ); } }