at path:ROOT / clients / vendor / punic / punic / src / Phone.php
run:R W Run
DIR
2026-04-08 19:42:30
R W Run
DIR
2026-04-08 19:53:13
R W Run
126.16 KB
2026-04-08 19:35:40
R W Run
4.19 KB
2026-04-08 19:35:40
R W Run
8.96 KB
2026-04-08 19:35:41
R W Run
24.16 KB
2026-04-08 19:35:40
R W Run
2 KB
2026-04-08 19:35:42
R W Run
3.93 KB
2026-04-08 19:35:41
R W Run
12.53 KB
2026-04-08 19:35:40
R W Run
17.07 KB
2026-04-08 19:35:39
R W Run
2.3 KB
2026-04-08 19:35:42
R W Run
6.93 KB
2026-04-08 19:35:39
R W Run
20.49 KB
2026-04-08 19:35:40
R W Run
13.16 KB
2026-04-08 19:35:39
R W Run
error_log
📄Phone.php
1<?php
2
3namespace Punic;
4
5/**
6 * Numbers helpers.
7 */
8class Phone
9{
10 /**
11 * Retrieve the list of the country calling codes for a specific country.
12 *
13 * @param string $territoryCode The country identifier ('001' for global systems, for instance satellite communications like Iridium)
14 *
15 * @return array Returns the list of country calling codes found for the specified country (eg: for 'US' you'll get array('1'))
16 */
17 public static function getPrefixesForTerritory($territoryCode)
18 {
19 $result = array();
20 if (is_string($territoryCode) && preg_match('/^([a-z]{2}|[0-9]{3})$/i', $territoryCode)) {
21 $territoryCode = strtoupper($territoryCode);
22 $data = Data::getGeneric('telephoneCodeData');
23 if (isset($data[$territoryCode])) {
24 $result = $data[$territoryCode];
25 }
26 }
27
28 return $result;
29 }
30
31 /**
32 * Retrieve the list of territory codes for a specific prefix.
33 *
34 * @param string $prefix The country calling code (for instance: '1')
35 *
36 * @return array Returns the list of territories for which the specified prefix is applicable (eg: for '1' you'll get array('US', 'AG', 'AI', 'CA', ...))
37 */
38 public static function getTerritoriesForPrefix($prefix)
39 {
40 $result = array();
41 if (is_string($prefix) && preg_match('/^[0-9]+$/', $prefix)) {
42 $data = Data::getGeneric('telephoneCodeData');
43 foreach ($data as $territoryCode => $prefixes) {
44 if (in_array($prefix, $prefixes)) {
45 $result[] = $territoryCode;
46 }
47 }
48 }
49
50 return $result;
51 }
52
53 /**
54 * Retrieve the max length of the country calling codes.
55 *
56 * @return int
57 */
58 public static function getMaxPrefixLength()
59 {
60 static $result;
61 if (!isset($result)) {
62 $maxLen = 0;
63 $data = Data::getGeneric('telephoneCodeData');
64 foreach ($data as $territoryCode => $prefixes) {
65 foreach ($prefixes as $prefix) {
66 $len = strlen($prefix);
67 if ($maxLen < $len) {
68 $maxLen = $len;
69 }
70 }
71 }
72 $result = $maxLen;
73 }
74
75 return $result;
76 }
77}
78