Passed
Pull Request — dev (#2038)
by Janko
10:55
created

SkillEnhancementLogRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 68.75%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 31
ccs 11
cts 16
cp 0.6875
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prototype() 0 4 1
A save() 0 6 1
A getForCrewman() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Repository;
6
7
use Doctrine\ORM\EntityRepository;
8
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Stu\Orm\Entity\CrewInterface;
10
use Stu\Orm\Entity\SkillEnhancementLog;
11
use Stu\Orm\Entity\SkillEnhancementLogInterface;
12
13
/**
14
 * @extends EntityRepository<SkillEnhancementLog>
15
 */
16
final class SkillEnhancementLogRepository extends EntityRepository implements SkillEnhancementLogRepositoryInterface
17
{
18
19
    #[Override]
20
    public function prototype(): SkillEnhancementLogInterface
21
    {
22
        return new SkillEnhancementLog();
23
    }
24
25
    #[Override]
26
    public function save(SkillEnhancementLogInterface $post): void
27
    {
28
        $em = $this->getEntityManager();
29
30
        $em->persist($post);
31
    }
32
33 1
    #[Override]
34
    public function getForCrewman(CrewInterface $crew): array
35
    {
36 1
        return $this->getEntityManager()
37 1
            ->createQuery(
38 1
                sprintf(
39 1
                    'SELECT el FROM %s el
40
                        WHERE el.crew_id = :crewId
41 1
                        ORDER BY el.id DESC',
42 1
                    SkillEnhancementLog::class
43 1
                )
44 1
            )
45 1
            ->setParameter('crewId', $crew->getId())
46 1
            ->getResult();
47
    }
48
}
49