1 | <?php |
||
13 | class Parser implements ParserInterface |
||
14 | { |
||
15 | /** |
||
16 | * Regular expression pattern for Outward code |
||
17 | */ |
||
18 | const OUTWARD = "/\d[A-Za-z]{1,2}$/i"; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * Regular expression pattern for Inward code |
||
23 | */ |
||
24 | const INWARD = "/\d[A-Za-z]{2}$/i"; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * Regular expression pattern for Area code |
||
29 | */ |
||
30 | const AREA = "/^[A-Za-z]{1,2}/i"; |
||
31 | |||
32 | |||
33 | /** |
||
34 | * Regular expression pattern for Sector code |
||
35 | */ |
||
36 | const SECTOR = "/^[A-Za-z]{1,2}\d[A-Za-z\d]?\s*\d/i"; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Regular expression pattern for Unit code |
||
41 | */ |
||
42 | const UNIT = "/[A-Za-z]{2}$/i"; |
||
43 | |||
44 | |||
45 | /** |
||
46 | * Regular expression pattern for District code |
||
47 | */ |
||
48 | const DISTRICT = "/^([A-Za-z]{1,2}\d)([A-Za-z])$/i"; |
||
49 | |||
50 | |||
51 | /** |
||
52 | * Regular expression pattern for Subdistrict code |
||
53 | */ |
||
54 | const SUBDISTRICT = "/^([A-Za-z]{1,2}\d)([A-Za-z])$/i"; |
||
55 | |||
56 | |||
57 | /** |
||
58 | * string $postcode |
||
59 | */ |
||
60 | private $postcode; |
||
61 | |||
62 | /** |
||
63 | * Validator $validator |
||
64 | */ |
||
65 | private $validator; |
||
66 | |||
67 | 1 | /** |
|
68 | * Constructor |
||
69 | 1 | * |
|
70 | 1 | * @param string $postcode |
|
71 | * @param Validator $validator |
||
72 | */ |
||
73 | public function __construct($postcode, Validator $validator = null) |
||
87 | |||
88 | /** |
||
89 | * @return string $outward |
||
90 | */ |
||
91 | public function outward() |
||
95 | |||
96 | /** |
||
97 | * @return string $inward |
||
98 | */ |
||
99 | public function inward() |
||
103 | |||
104 | |||
105 | /** |
||
106 | * @return string $area |
||
107 | */ |
||
108 | public function area() |
||
112 | 1 | ||
113 | /** |
||
114 | * @return string $district |
||
115 | */ |
||
116 | public function district() |
||
120 | 1 | ||
121 | /** |
||
122 | * Subdistrict code |
||
123 | * |
||
124 | * @return string Example: "AA9A" |
||
125 | */ |
||
126 | public function subdistrict() |
||
130 | |||
131 | /** |
||
132 | * @return string $sector |
||
133 | */ |
||
134 | public function sector() |
||
138 | 1 | ||
139 | 1 | ||
140 | 1 | /** |
|
141 | 1 | * @return string $unit |
|
142 | 1 | */ |
|
143 | 1 | public function unit() |
|
147 | |||
148 | /** |
||
149 | * @return array |
||
150 | */ |
||
151 | public function parse() |
||
163 | } |
||
164 |