hasOptionalArgument() public method

Returns whether the format contains an optional argument.
public hasOptionalArgument ( boolean $includeBase = true ) : boolean
$includeBase boolean Whether to include arguments in the base format in the search.
return boolean Returns `true` if the format contains an optional argument and `false` otherwise.
Example #1
0
 /**
  * Returns whether the builder contains an optional argument.
  *
  * @param bool $includeBase Whether to include arguments in the base format
  *                          in the search.
  *
  * @return bool Returns `true` if the builder contains an optional argument
  *              and `false` otherwise.
  */
 public function hasOptionalArgument($includeBase = true)
 {
     Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s');
     if ($this->hasOptionalArg) {
         return true;
     }
     if ($includeBase && $this->baseFormat) {
         return $this->baseFormat->hasOptionalArgument();
     }
     return false;
 }
Example #2
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testHasOptionalArgumentFailsIfIncludeBaseNoBoolean()
 {
     $format = new ArgsFormat();
     $format->hasOptionalArgument(1234);
 }