Completed
Pull Request — master (#142)
by Ihor
15:10
created

Seat::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace AppBundle\Domain\Seat;
4
5
use AppBundle\Entity\Venue;
6
use AppBundle\Exception\NotFoundException;
7
use AppBundle\Entity\Seat as SeatEntity;
8
use AppBundle\Repository\SeatRepository;
9
10
class Seat implements SeatInterface
11
{
12
    /** @var SeatRepository */
13
    private $seatRepository;
14
15
    /**
16
     * Domain Seat constructor.
17
     *
18
     * @param SeatRepository $seatRepository
19
     */
20
    public function __construct(
21
        SeatRepository $seatRepository
22
    ) {
23
        $this->seatRepository = $seatRepository;
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function getByVenue(Venue $venue): array
30
    {
31
        /** @var SeatEntity[] $seats */
32
        $seats = $this->seatRepository->findByVenue($venue);
33
        if (empty($seats)) {
34
            throw new NotFoundException('Seats not found by venue: '.$venue->getTitle());
35
        }
36
37
        return $seats;
38
    }
39
}
40