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

CanonicalPlaceRepository::findCanonicalFor()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
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