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

Seat   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getByVenue() 0 10 2
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