Conditions | 4 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public static function execute(string $description) |
||
21 | { |
||
22 | // Check that the place description contains a comma string |
||
23 | if (strpos($description, ', ') !== false) { |
||
24 | // Separate city and state strings |
||
25 | list($city, $state) = explode(', ', $description); |
||
26 | |||
27 | // Check if the state string contains more than a state code |
||
28 | if (strlen(trim($state)) > 2 && strpos($state, ' ') !== false) { |
||
29 | // Extract the zip code |
||
30 | list($state, $zip) = explode(' ', $state); |
||
31 | } |
||
32 | return [$city, $state]; |
||
33 | |||
34 | } else { |
||
35 | return ['', self::stateAbbreviation($description)]; |
||
36 | } |
||
39 |