| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | 2 | public function getCoordinates(String $search) : String |
|
| 32 | { |
||
| 33 | 2 | $valid = preg_match('/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?),[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/', $search); |
|
| 34 | 2 | if (!$valid) { |
|
| 35 | 2 | $result = $this->geocoder->geocode($search); |
|
| 36 | 2 | if ($result["status"]["code"] == 400) { |
|
| 37 | 1 | return ""; |
|
| 38 | } |
||
| 39 | 2 | $search = $result["results"][0]["geometry"]["lat"] . "," . $result["results"][0]["geometry"]["lng"]; |
|
| 40 | } |
||
| 41 | |||
| 42 | 2 | return $search; |
|
| 43 | } |
||
| 45 |