@@ 384-408 (lines=25) @@ | ||
381 | * @throws NoSuchArgumentException If the argument with the given name or |
|
382 | * position does not exist. |
|
383 | */ |
|
384 | public function getArgument($name, $includeBase = true) |
|
385 | { |
|
386 | if (!is_int($name)) { |
|
387 | Assert::string($name, 'The argument name must be a string or an integer. Got: %s'); |
|
388 | Assert::notEmpty($name, 'The argument name must not be empty.'); |
|
389 | } |
|
390 | ||
391 | Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s'); |
|
392 | ||
393 | if (is_int($name)) { |
|
394 | $arguments = array_values($this->getArguments($includeBase)); |
|
395 | ||
396 | if (!isset($arguments[$name])) { |
|
397 | throw NoSuchArgumentException::forPosition($name); |
|
398 | } |
|
399 | } else { |
|
400 | $arguments = $this->getArguments($includeBase); |
|
401 | ||
402 | if (!isset($arguments[$name])) { |
|
403 | throw NoSuchArgumentException::forArgumentName($name); |
|
404 | } |
|
405 | } |
|
406 | ||
407 | return $arguments[$name]; |
|
408 | } |
|
409 | ||
410 | /** |
|
411 | * Returns all arguments of the format. |
@@ 667-691 (lines=25) @@ | ||
664 | * @throws NoSuchArgumentException If the argument with the given name or |
|
665 | * position does not exist. |
|
666 | */ |
|
667 | public function getArgument($name, $includeBase = true) |
|
668 | { |
|
669 | if (!is_int($name)) { |
|
670 | Assert::string($name, 'The argument name must be a string or integer. Got: %s'); |
|
671 | Assert::notEmpty($name, 'The argument name must not be empty.'); |
|
672 | } |
|
673 | ||
674 | Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s'); |
|
675 | ||
676 | if (is_int($name)) { |
|
677 | $arguments = array_values($this->getArguments($includeBase)); |
|
678 | ||
679 | if (!isset($arguments[$name])) { |
|
680 | throw NoSuchArgumentException::forPosition($name); |
|
681 | } |
|
682 | } else { |
|
683 | $arguments = $this->getArguments($includeBase); |
|
684 | ||
685 | if (!isset($arguments[$name])) { |
|
686 | throw NoSuchArgumentException::forArgumentName($name); |
|
687 | } |
|
688 | } |
|
689 | ||
690 | return $arguments[$name]; |
|
691 | } |
|
692 | ||
693 | /** |
|
694 | * Returns all arguments added to the builder. |