Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • AbstractValidator
  • Callback
  • Equals
  • InArray
  • IsArray
  • IsBankAccountNumber
  • IsBirthNumber
  • IsCompanyId
  • IsCountryCode
  • IsDate
  • IsDateTime
  • IsEmail
  • IsIban
  • IsInt
  • IsIpV4
  • IsIpV6
  • IsNumeric
  • IsPhone
  • IsTaxId
  • IsUrl
  • IsZipCode
  • LessThan
  • NotEmpty
  • Regex
  • StringLengthBetween
  • StringLengthGreaterThan
  • StringLengthLessThan
  • Upload

Interfaces

  • ErrorMessage

Exceptions

  • Exception
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * Jyxo PHP Library
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file license.txt.
10:  * It is also available through the world-wide-web at this URL:
11:  * https://github.com/jyxo/php/blob/master/license.txt
12:  */
13: 
14: namespace Jyxo\Input\Validator;
15: 
16: /**
17:  * (Czech and Slovak) phone number validator.
18:  *
19:  * @category Jyxo
20:  * @package Jyxo\Input
21:  * @subpackage Validator
22:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
23:  * @license https://github.com/jyxo/php/blob/master/license.txt
24:  * @author Jaroslav Hanslík
25:  * @author Jakub Tománek
26:  */
27: class IsPhone extends \Jyxo\Input\Validator\AbstractValidator
28: {
29:     /**
30:      * Validates a value.
31:      *
32:      * @param mixed $value Input value
33:      * @return boolean
34:      */
35:     public function isValid($value)
36:     {
37:         // Removes spaces
38:         $phoneNumber = preg_replace('~\s+~', '', (string) $value);
39: 
40:         if (preg_match('~^1\d{2,8}$~', $phoneNumber)) {
41:             // Special numbers
42:             return true;
43:         } elseif (preg_match('~^8\d{8}$~', $phoneNumber)) {
44:             // Numbers with special tariffs
45:             return true;
46:         } elseif (preg_match('~^(?:(?:[+]|00)42(?:0|1))?[2-79]\d{8}$~', $phoneNumber)) {
47:             // Normal numbers
48:             return true;
49:         } else {
50:             return false;
51:         }
52:     }
53: }
54: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0