N98\Util\Console\Helper\ParameterHelper::validateArgument PHP Метод

validateArgument() приватный Метод

private validateArgument ( Symfony\Component\Console\Output\OutputInterface $output, string $name, string $value, Symfony\Component\Validator\Constraints\Collection $constraints ) : string
$output Symfony\Component\Console\Output\OutputInterface
$name string
$value string
$constraints Symfony\Component\Validator\Constraints\Collection The constraint(s) to validate against.
Результат string
    private function validateArgument(OutputInterface $output, $name, $value, $constraints)
    {
        if (strlen($value)) {
            $errors = $this->validateValue($name, $value, $constraints);
            if ($errors->count() > 0) {
                $output->writeln('<error>' . $errors[0]->getMessage() . '</error>');
            } else {
                return $value;
            }
        }
        $question = '<question>' . ucfirst($name) . ': </question>';
        $value = $this->askAndValidate($output, $question, function ($inputValue) use($constraints, $name) {
            $errors = $this->validateValue($name, $inputValue, $constraints);
            if ($errors->count() > 0) {
                throw new InvalidArgumentException($errors[0]->getMessage());
            }
            return $inputValue;
        });
        return $value;
    }