LocationProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
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