LocationProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 16
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\DataProvider;
4
5
use App\DTO\City;
6
use Symfony\Component\Serializer\Exception\ExceptionInterface;
7
use Symfony\Component\Serializer\SerializerInterface;
8
9
class LocationProvider
10
{
11
    /** @var City[] */
12
    private array $cities;
13
14
    /**
15
     * @throws ExceptionInterface
16
     */
17
    public function __construct(array $cities, SerializerInterface $serializer)
18
    {
19
        $this->cities = $serializer->denormalize($cities, City::class . '[]');
20
    }
21
22
    public function find(string $name): ?City
23
    {
24
        return $this->cities[$name] ?? null;
25
    }
26
}
27