Passed
Push — master ( 5bdcad...49c220 )
by Dejan
02:59
created

DoctrineCitiesRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Angelov\Donut\Places\Repositories;
4
5
use Angelov\Donut\Core\Exceptions\ResourceNotFoundException;
6
use Angelov\Donut\Places\City;
7
use Doctrine\ORM\EntityManagerInterface;
8
use Donut\Places\Repositories\CitiesRepositoryInterface;
9
10
class DoctrineCitiesRepository implements CitiesRepositoryInterface
11
{
12
    private $entityManager;
13
14
    public function __construct(EntityManagerInterface $entityManager)
15
    {
16
        $this->entityManager = $entityManager;
17
    }
18
19
    public function find(string $id) : City
20
    {
21
        $found = $this->entityManager->find(City::class, $id);
22
23
        if ($found) {
24
            return $found;
25
        }
26
27
        throw new ResourceNotFoundException();
28
    }
29
}
30