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

PerformanceEvent::getById()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace AppBundle\Domain\PerformanceEvent;
4
5
use AppBundle\Exception\NotFoundException;
6
use AppBundle\Repository\PerformanceEventRepository;
7
use AppBundle\Entity\PerformanceEvent as PerformanceEventEntity;
8
9
class PerformanceEvent implements PerformanceEventInterface
10
{
11
    /** @var PerformanceEventRepository */
12
    private $performanceEventRepository;
13
14
    /**
15
     * Domain PerformanceEvent constructor.
16
     *
17
     * @param PerformanceEventRepository $performanceEventRepository
18
     */
19
    public function __construct(
20
        PerformanceEventRepository $performanceEventRepository
21
    ) {
22
        $this->performanceEventRepository = $performanceEventRepository;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function getById(int $id): PerformanceEventEntity
29
    {
30
        /** @var PerformanceEventEntity $performanceEventEntity */
31
        $performanceEventEntity = $this->performanceEventRepository->find($id);
32
        if (!$performanceEventEntity) {
33
            throw new NotFoundException('Performance Event not found by ID: '.$id);
34
        }
35
36
        return $performanceEventEntity;
37
    }
38
}
39