Completed
Pull Request — master (#421)
by Jonas
03:05
created

CanonicalPlaceRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findCanonicalFor() 0 10 2
1
<?php
2
3
namespace CultuurNet\UDB3\Place;
4
5
class CanonicalPlaceRepository
6
{
7
    /**
8
     * @var PlaceRepository
9
     */
10
    private $repository;
11
12
    public function __construct(PlaceRepository $repository)
13
    {
14
        $this->repository = $repository;
15
    }
16
17
    public function findCanonicalFor(string $placeId): Place
18
    {
19
        /** @var Place $place */
20
        $place = $this->repository->load($placeId);
21
        while ($place->getCanonicalPlaceId()) {
22
            $place = $this->repository->load($place->getCanonicalPlaceId());
23
        }
24
25
        return $place;
26
    }
27
}
28