Conditions | 4 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
35 | public function detect(): ?Generator |
||
36 | { |
||
37 | $response = $this->getOriginalResponse(); |
||
38 | |||
39 | if (0 === $response->count()) { |
||
40 | return null; |
||
41 | } |
||
42 | |||
43 | /** @var EntityAnnotation $entity */ |
||
44 | foreach ($response as $entity) { |
||
45 | yield new LandmarkData( |
||
46 | name: $entity->getDescription(), |
||
47 | locations: array_map(function (LocationInfo $location) { |
||
48 | $info = $location->getLatLng(); |
||
49 | |||
50 | if (is_null($info)) { |
||
51 | return null; |
||
52 | } |
||
53 | |||
54 | return new LocationData($info->getLatitude(), $info->getLongitude()); |
||
55 | }, iterator_to_array($entity->getLocations()->getIterator())) |
||
56 | ); |
||
60 |