| Conditions | 5 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | public function setImageLocation( |
||
| 34 | Image $image, |
||
| 35 | bool $overwriteExisting = false |
||
| 36 | ): bool |
||
| 37 | { |
||
| 38 | if ($overwriteExisting === false && $image->hasLocation()) { |
||
| 39 | $this->logger->info('Deliberately not overwriting existing image location'); |
||
| 40 | return false; |
||
| 41 | } |
||
| 42 | |||
| 43 | if (!$image->hasLatlng()) { |
||
| 44 | $this->logger->info('Ignoring image that has no latlng.'); |
||
| 45 | return false; |
||
| 46 | } |
||
| 47 | |||
| 48 | $neighbourhood = $this->neighbourhoodRepository |
||
| 49 | ->findByLatlng($image->getLatitude(), $image->getLongitude()); |
||
| 50 | |||
| 51 | if ($neighbourhood === null) { |
||
| 52 | return false; |
||
| 53 | } |
||
| 54 | |||
| 55 | $image->setLocation($neighbourhood->getLsoa11ln()); |
||
| 56 | return true; |
||
| 57 | } |
||
| 58 | } |