@@ 15-26 (lines=12) @@ | ||
12 | * @param string $postcode |
|
13 | * @return false|PostCode |
|
14 | */ |
|
15 | public function lookup($postcode) |
|
16 | { |
|
17 | $jsonurl = "https://api.postcodes.io/postcodes/".$postcode; |
|
18 | $json = $this->request($jsonurl); |
|
19 | $decoded = json_decode($json, true); |
|
20 | if ($decoded['status'] == 200) { |
|
21 | return new PostCode($decoded['result']); |
|
22 | } else { |
|
23 | return false; |
|
24 | } |
|
25 | return false; |
|
26 | } |
|
27 | ||
28 | ||
29 | public function bulkLookup($postcodes) |
|
@@ 90-102 (lines=13) @@ | ||
87 | /** |
|
88 | * @return bool|PostCode a random PostCode |
|
89 | */ |
|
90 | public function random() |
|
91 | { |
|
92 | $jsonurl = "https://api.postcodes.io/random/postcodes/"; |
|
93 | $json = $this->request($jsonurl); |
|
94 | ||
95 | $decoded = json_decode($json, true); |
|
96 | if ($decoded['status'] == 200) { |
|
97 | return new PostCode($decoded['result']); |
|
98 | } else { |
|
99 | return false; |
|
100 | } |
|
101 | return false; |
|
102 | } |
|
103 | ||
104 | ||
105 | public function validate($postcode) |