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