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

DoctrineCitiesRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A find() 0 9 2
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