Passed
Push — feature/VSVGVQ-7 ( 1c51a3...ea6450 )
by steven
03:02
created

QuestionDoctrineRepository::getRepositoryName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\Question\Repositories;
4
5
use Ramsey\Uuid\UuidInterface;
6
use VSV\GVQ_API\Question\Models\Question;
7
8
class QuestionDoctrineRepository extends AbstractDoctrineRepository implements QuestionRepository
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function getRepositoryName(): string
14
    {
15
        return Question::class;
16
    }
17
18
    /**
19
     * @param Question $question
20
     * @throws \Doctrine\ORM\ORMException
21
     * @throws \Doctrine\ORM\OptimisticLockException
22
     */
23
    public function save(Question $question): void
24
    {
25
        $this->entityManager->persist($question);
26
        $this->entityManager->flush();
27
    }
28
29
    /**
30
     * @param UuidInterface $id
31
     * @return null|Question
32
     */
33
    public function getById(UuidInterface $id): ?Question
34
    {
35
        /** @var Question|null $question */
36
        $question = $this->objectRepository->findOneBy(
37
            [
38
                'id' => $id,
39
            ]
40
        );
41
42
        return $question;
43
    }
44
}
45