PhoneNumber.php
108 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Faker\Provider\en_SG; |
| 4 | |
| 5 | class PhoneNumber extends \Faker\Provider\PhoneNumber |
| 6 | { |
| 7 | protected static $internationalCodePrefix = array( |
| 8 | '+65', |
| 9 | '65', |
| 10 | ); |
| 11 | |
| 12 | protected static $zeroToEight = array(0, 1, 2, 3, 4, 5, 6, 7, 8); |
| 13 | |
| 14 | protected static $oneToEight = array(1, 2, 3, 4, 5, 6, 7, 8); |
| 15 | |
| 16 | protected static $mobileNumberFormats = array( |
| 17 | '{{internationalCodePrefix}}9{{zeroToEight}}## ####', |
| 18 | '{{internationalCodePrefix}} 9{{zeroToEight}}## ####', |
| 19 | '9{{zeroToEight}}## ####', |
| 20 | '{{internationalCodePrefix}}8{{oneToEight}}## ####', |
| 21 | '{{internationalCodePrefix}} 8{{oneToEight}}## ####', |
| 22 | '8{{oneToEight}}## ####', |
| 23 | ); |
| 24 | |
| 25 | protected static $fixedLineNumberFormats = array( |
| 26 | '{{internationalCodePrefix}}6### ####', |
| 27 | '{{internationalCodePrefix}} 6### ####', |
| 28 | '6### ####', |
| 29 | ); |
| 30 | |
| 31 | // http://en.wikipedia.org/wiki/Telephone_numbers_in_Singapore#Numbering_plan |
| 32 | protected static $formats = array( |
| 33 | '{{mobileNumber}}', |
| 34 | '{{fixedLineNumber}}', |
| 35 | ); |
| 36 | |
| 37 | protected static $voipNumber = array( |
| 38 | '{{internationalCodePrefix}}3### ####', |
| 39 | '{{internationalCodePrefix}} 3### ####', |
| 40 | '3### ####', |
| 41 | ); |
| 42 | |
| 43 | protected static $tollFreeInternationalNumber = array( |
| 44 | '800 ### ####' |
| 45 | ); |
| 46 | |
| 47 | protected static $tollFreeLineNumber = array( |
| 48 | '1800 ### ####' |
| 49 | ); |
| 50 | |
| 51 | protected static $premiumPhoneNumber = array( |
| 52 | '1900 ### ####' |
| 53 | ); |
| 54 | |
| 55 | public function tollFreeInternationalNumber() |
| 56 | { |
| 57 | return static::randomElement(static::$tollFreeInternationalNumber); |
| 58 | } |
| 59 | |
| 60 | public function tollFreeLineNumber() |
| 61 | { |
| 62 | return static::randomElement(static::$tollFreeLineNumber); |
| 63 | } |
| 64 | |
| 65 | public function premiumPhoneNumber() |
| 66 | { |
| 67 | return static::randomElement(static::$premiumPhoneNumber); |
| 68 | } |
| 69 | |
| 70 | public function mobileNumber() |
| 71 | { |
| 72 | $format = static::randomElement(static::$mobileNumberFormats); |
| 73 | |
| 74 | return static::numerify($this->generator->parse($format)); |
| 75 | } |
| 76 | |
| 77 | public function fixedLineNumber() |
| 78 | { |
| 79 | $format = static::randomElement(static::$fixedLineNumberFormats); |
| 80 | |
| 81 | return static::numerify($this->generator->parse($format)); |
| 82 | } |
| 83 | |
| 84 | public function voipNumber() |
| 85 | { |
| 86 | $format = static::randomElement(static::$voipNumber); |
| 87 | |
| 88 | return $this->generator->parse($format); |
| 89 | } |
| 90 | |
| 91 | public function internationalCodePrefix() |
| 92 | { |
| 93 | $format = static::randomElement(static::$internationalCodePrefix); |
| 94 | |
| 95 | return $this->generator->parse($format); |
| 96 | } |
| 97 | |
| 98 | public function zeroToEight() |
| 99 | { |
| 100 | return static::randomElement(static::$zeroToEight); |
| 101 | } |
| 102 | |
| 103 | public function oneToEight() |
| 104 | { |
| 105 | return static::randomElement(static::$oneToEight); |
| 106 | } |
| 107 | } |
| 108 |