1 | <?php |
||
12 | class Parser implements ParserInterface |
||
13 | { |
||
14 | /** |
||
15 | * Regular expression pattern for Outward code |
||
16 | */ |
||
17 | const OUTWARD = "/\d[A-Za-z]{1,2}$/i"; |
||
18 | |||
19 | |||
20 | /** |
||
21 | * Regular expression pattern for Inward code |
||
22 | */ |
||
23 | const INWARD = "/\d[A-Za-z]{2}$/i"; |
||
24 | |||
25 | |||
26 | /** |
||
27 | * Regular expression pattern for Area code |
||
28 | */ |
||
29 | const AREA = "/^[A-Za-z]{1,2}/i"; |
||
30 | |||
31 | |||
32 | /** |
||
33 | * Regular expression pattern for Sector code |
||
34 | */ |
||
35 | const SECTOR = "/^[A-Za-z]{1,2}\d[A-Za-z\d]?\s*\d/i"; |
||
36 | |||
37 | |||
38 | /** |
||
39 | * Regular expression pattern for Unit code |
||
40 | */ |
||
41 | const UNIT = "/[A-Za-z]{2}$/i"; |
||
42 | |||
43 | |||
44 | /** |
||
45 | * Regular expression pattern for District code |
||
46 | */ |
||
47 | const DISTRICT = "/^([A-Za-z]{1,2}\d)([A-Za-z])$/i"; |
||
48 | |||
49 | |||
50 | /** |
||
51 | * Regular expression pattern for Subdistrict code |
||
52 | */ |
||
53 | const SUBDISTRICT = "/^([A-Za-z]{1,2}\d)([A-Za-z])$/i"; |
||
54 | |||
55 | |||
56 | /** |
||
57 | * Postcode $postcode |
||
58 | */ |
||
59 | private $postcode; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * Constructor |
||
64 | * |
||
65 | * @param Postcode $postcode |
||
66 | */ |
||
67 | public function __construct(Postcode $postcode) |
||
71 | |||
72 | /** |
||
73 | * @return string $outward |
||
74 | */ |
||
75 | public function outward() |
||
79 | |||
80 | /** |
||
81 | * @return string $inward |
||
82 | */ |
||
83 | public function inward() |
||
87 | |||
88 | |||
89 | /** |
||
90 | * @return string $area |
||
91 | */ |
||
92 | public function area() |
||
96 | |||
97 | /** |
||
98 | * @return string $district |
||
99 | */ |
||
100 | public function district() |
||
104 | |||
105 | /** |
||
106 | * Subdistrict code |
||
107 | * |
||
108 | * @return string Example: "AA9A" |
||
109 | */ |
||
110 | public function subdistrict() |
||
114 | |||
115 | /** |
||
116 | * @return string $sector |
||
117 | */ |
||
118 | public function sector() |
||
122 | |||
123 | |||
124 | /** |
||
125 | * @return string $unit |
||
126 | */ |
||
127 | public function unit() |
||
131 | |||
132 | /** |
||
133 | * @return array |
||
134 | */ |
||
135 | public function parse() |
||
139 | } |
||
140 |