Completed
Push — master ( 027cf3...96bb6d )
by Matt
04:34
created

LocationService::setImageLocation()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 12
nc 4
nop 2
dl 0
loc 24
rs 9.5555
c 1
b 0
f 0
1
<?php
2
3
namespace App\Service;
4
5
use App\Entity\Image;
6
use App\Entity\Neighbourhood;
7
use App\Repository\NeighbourhoodRepository;
8
use Doctrine\ORM\EntityManagerInterface;
9
use GuzzleHttp\Client;
10
use GuzzleHttp\HandlerStack;
11
use PhpParser\Node\Expr\Cast\Double;
12
use Psr\Log\LoggerInterface;
13
use Spatie\GuzzleRateLimiterMiddleware\RateLimiterMiddleware;
14
15
class LocationService
16
{
17
    /** @var NeighbourhoodRepository */
18
    private $neighbourhoodRepository;
19
20
    public function __construct(
21
        NeighbourhoodRepository $neighbourhoodRepository)
22
    {
23
        $this->neighbourhoodRepository = $neighbourhoodRepository;
24
    }
25
26
    public function getLocationName(?float $lat, ?float $lng):?string
27
    {
28
        if ($lat === null || $lng === null) {
29
            return null;
30
        }
31
        $neighbourhood = $this
32
            ->neighbourhoodRepository
33
            ->findByLatlng($lat, $lng);
34
35
        if ($neighbourhood === null) {
36
            return null;
37
        } else {
38
            return $neighbourhood->getLsoa11ln();
39
        }
40
    }
41
}