LocationService::getLocationName()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 9
nc 3
nop 2
dl 0
loc 13
rs 9.9666
c 0
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
}