/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Console
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Console/ConsoleInputArgument.php (5492B)
$value) {
$this->{'_' . $key} = $value;
}
} else {
/** @psalm-suppress PossiblyInvalidPropertyAssignmentValue */
$this->_name = $name;
$this->_help = $help;
$this->_required = $required;
$this->_choices = $choices;
}
}
/**
* Get the value of the name attribute.
*
* @return string Value of this->_name.
*/
public function name(): string
{
return $this->_name;
}
/**
* Checks if this argument is equal to another argument.
*
* @param \Cake\Console\ConsoleInputArgument $argument ConsoleInputArgument to compare to.
* @return bool
*/
public function isEqualTo(ConsoleInputArgument $argument): bool
{
return $this->usage() === $argument->usage();
}
/**
* Generate the help for this argument.
*
* @param int $width The width to make the name of the option.
* @return string
*/
public function help(int $width = 0): string
{
$name = $this->_name;
if (strlen($name) < $width) {
$name = str_pad($name, $width, ' ');
}
$optional = '';
if (!$this->isRequired()) {
$optional = '
(optional)';
}
if ($this->_choices) {
$optional .= sprintf('
(choices: %s)', implode('|', $this->_choices));
}
return sprintf('%s%s%s', $name, $this->_help, $optional);
}
/**
* Get the usage value for this argument
*
* @return string
*/
public function usage(): string
{
$name = $this->_name;
if ($this->_choices) {
$name = implode('|', $this->_choices);
}
$name = '<' . $name . '>';
if (!$this->isRequired()) {
$name = '[' . $name . ']';
}
return $name;
}
/**
* Check if this argument is a required argument
*
* @return bool
*/
public function isRequired(): bool
{
return $this->_required;
}
/**
* Check that $value is a valid choice for this argument.
*
* @param string $value The choice to validate.
* @return true
* @throws \Cake\Console\Exception\ConsoleException
*/
public function validChoice(string $value): bool
{
if (empty($this->_choices)) {
return true;
}
if (!in_array($value, $this->_choices, true)) {
throw new ConsoleException(
sprintf(
'"%s" is not a valid value for %s. Please use one of "%s"',
$value,
$this->_name,
implode(', ', $this->_choices)
)
);
}
return true;
}
/**
* Append this arguments XML representation to the passed in SimpleXml object.
*
* @param \SimpleXMLElement $parent The parent element.
* @return \SimpleXMLElement The parent with this argument appended.
*/
public function xml(SimpleXMLElement $parent): SimpleXMLElement
{
$option = $parent->addChild('argument');
$option->addAttribute('name', $this->_name);
$option->addAttribute('help', $this->_help);
$option->addAttribute('required', (string)(int)$this->isRequired());
$choices = $option->addChild('choices');
foreach ($this->_choices as $valid) {
$choices->addChild('choice', $valid);
}
return $parent;
}
}