| Conditions | 6 |
| Paths | 7 |
| Total Lines | 25 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | 3 | public function snapToRoads(array|string|null $path = null, array $params = []): RequestInterface |
|
| 25 | { |
||
| 26 | 3 | if (is_array($path)) { |
|
| 27 | 1 | $positions = []; |
|
| 28 | 1 | foreach ($path as $key => $eachPathArray) { |
|
| 29 | 1 | $positions[] = implode(',', $eachPathArray); |
|
| 30 | } |
||
| 31 | 1 | $params['path'] = implode('|', $positions); |
|
| 32 | 2 | } elseif (is_string($path)) { |
|
|
|
|||
| 33 | 1 | $params['path'] = $path; |
|
| 34 | } else { |
||
| 35 | 1 | throw new ServiceException('Unknown path format. Pass array of arrays of floats or the string itself.'); |
|
| 36 | } |
||
| 37 | |||
| 38 | 2 | if (isset($params['interpolate'])) { |
|
| 39 | 2 | if ($params['interpolate']) { |
|
| 40 | 1 | $params['interpolate'] = 'true'; |
|
| 41 | } else { |
||
| 42 | 1 | unset($params['interpolate']); |
|
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | 2 | return $this->getWithDefaults( |
|
| 47 | 2 | 'https://roads.googleapis.com/v1/snapToRoads', |
|
| 48 | 2 | $this->queryParams($params) |
|
| 49 | 2 | ); |
|
| 52 |