public static function phone($check)
{
$pattern = '/^0(6[\\s-]?[1-9]\\d{7}|[1-9]\\d[\\s-]?[1-9]\\d{6}|[1-9]\\d{2}[\\s-]?[1-9]\\d{5})$/';
return (bool) preg_match($pattern, $check);
}
/** * test the phone method of NlValidation * * @return void */ public function testPhone() { $this->assertTrue(NlValidation::phone('020-5045100')); $this->assertTrue(NlValidation::phone('0572-212121')); $this->assertTrue(NlValidation::phone('0205045100')); $this->assertTrue(NlValidation::phone('0572212121')); $this->assertTrue(NlValidation::phone('0653123456')); $this->assertTrue(NlValidation::phone('06-53123456')); $this->assertFalse(NlValidation::phone('020-50451009')); }