Ejemplo n.º 1
0
 /**
  * Creates the parameter.
  *
  * @param string      $name         The parameter name.
  * @param int         $flags        A bitwise combination of the flag
  *                                  constants in this class.
  * @param null        $defaultValue The default value of the parameter. Must
  *                                  only be set for optional parameters.
  * @param string|null $description  A human-readable description.
  */
 public function __construct($name, $flags = self::OPTIONAL, $defaultValue = null, $description = null)
 {
     Assert::parameterName($name);
     Assert::nullOrInteger($flags, 'The parameter "$flags" must be an integer or null. Got: %s');
     Assert::nullOrParameterValue($defaultValue);
     Assert::nullOrString($description, 'The parameter description must be a string or null. Got: %s');
     Assert::nullOrNotEmpty($description, 'The parameter description must not be empty.');
     if ($flags & self::REQUIRED && null !== $defaultValue) {
         throw new RuntimeException('Required parameters cannot have default values.');
     }
     $this->name = $name;
     $this->flags = (int) $flags;
     $this->defaultValue = $defaultValue;
     $this->description = $description;
 }