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

CanonicalPlaceRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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