Cake\Localized\Validation\DeValidation::phone PHP Method

phone() public static method

Checks a phone number for Germany.
public static phone ( string $check ) : boolean
$check string The value to check.
return boolean Success.
    public static function phone($check)
    {
        $pattern = '/^[0-9\\/. \\-]*$/';
        return (bool) preg_match($pattern, $check);
    }

Usage Example

Example #1
0
 /**
  * test the phone method of DeValidation
  *
  * @return void
  */
 public function testPhone()
 {
     $this->assertTrue(DeValidation::phone('0123456789'));
     $this->assertFalse(DeValidation::phone('sometext'));
 }