length() public static method

Assert that string has a given length.
public static length ( mixed $value, integer $length, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$value mixed
$length integer
$message string | null
$propertyPath string | null
$encoding string
return boolean
Exemplo n.º 1
0
 /**
  * isEmpty.
  *
  * @return bool
  */
 public function isEmpty()
 {
     try {
         Assertion::length($this->value, 0);
         return true;
     } catch (AssertionInvalidArgumentException $exception) {
         return false;
     }
 }
Exemplo n.º 2
0
 public function testLengthValidForGivenEncoding()
 {
     Assertion::length("址", 1, null, null, 'utf8');
 }
Exemplo n.º 3
0
 /**
  * Validate EAN:
  * length = 13
  * @param string $ean
  */
 public static function ean($ean)
 {
     Assert::length($ean, 13);
 }