| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function sanitizePhoneNumber(string $number, $defaultRegion = 'NL'): string |
||
| 28 | { |
||
| 29 | $util = PhoneNumberUtil::getInstance(); |
||
| 30 | $region = strpos($number, '+') === false ? $defaultRegion : 'ZZ'; |
||
| 31 | $proto = $util->parse($number, $region); |
||
| 32 | |||
| 33 | if ( |
||
| 34 | $util->isViablePhoneNumber($number) === false |
||
| 35 | || $util->isValidNumber($proto) === false |
||
| 36 | ) { |
||
| 37 | throw new NumberParseException( |
||
| 38 | NumberParseException::NOT_A_NUMBER, |
||
| 39 | "The string supplied did not seem to be a phone number." |
||
| 40 | ); |
||
| 41 | } |
||
| 42 | |||
| 43 | return '00' . $proto->getCountryCode() . $proto->getNationalNumber(); |
||
| 44 | } |
||
| 46 |