Passed
Push — dev ( 79c88c...be1bbd )
by Nico
05:18
created

AllianceJobRepository::truncateByUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 11
ccs 0
cts 9
cp 0
crap 2
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A AllianceJobRepository::getJobsWithFounderPermission() 0 9 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\AllianceJob;
10
11
/**
12
 * @extends EntityRepository<AllianceJob>
13
 */
14
final class AllianceJobRepository extends EntityRepository implements AllianceJobRepositoryInterface
15
{
16
    #[Override]
17
    public function prototype(): AllianceJob
18
    {
19
        return new AllianceJob();
20
    }
21
22
    #[Override]
23
    public function save(AllianceJob $post): void
24
    {
25
        $em = $this->getEntityManager();
26
        $em->persist($post);
27
    }
28
29
    #[Override]
30
    public function delete(AllianceJob $post): void
31
    {
32
        $em = $this->getEntityManager();
33
        $em->remove($post);
34
    }
35
36
    #[Override]
37
    public function getByAlliance(int $allianceId): array
38
    {
39
        return $this->createQueryBuilder('aj')
40
            ->where('aj.alliance = :allianceId')
41
            ->setParameter('allianceId', $allianceId)
42
            ->getQuery()
43
            ->getResult();
44
    }
45
46
    #[Override]
47
    public function truncateByAlliance(int $allianceId): void
48
    {
49
        $this->getEntityManager()->createQuery(
50
            sprintf(
51
                'DELETE FROM %s aj WHERE aj.alliance = :allianceId',
52
                AllianceJob::class
53
            )
54
        )->setParameters([
55
            'allianceId' => $allianceId,
56
        ])->execute();
57
    }
58
59
    #[Override]
60
    public function getJobsWithFounderPermission(int $allianceId): array
61
    {
62
        return $this->createQueryBuilder('aj')
63
            ->where('aj.alliance = :allianceId')
64
            ->andWhere('aj.is_founder_permission = true')
65
            ->setParameter('allianceId', $allianceId)
66
            ->getQuery()
67
            ->getResult();
68
    }
69
70
    #[Override]
71
    public function getJobsWithSuccessorPermission(int $allianceId): array
72
    {
73
        return $this->createQueryBuilder('aj')
74
            ->where('aj.alliance = :allianceId')
75
            ->andWhere('aj.is_successor_permission = true')
76
            ->setParameter('allianceId', $allianceId)
77
            ->getQuery()
78
            ->getResult();
79
    }
80
81
    #[Override]
82
    public function getJobsWithDiplomaticPermission(int $allianceId): array
83
    {
84
        return $this->createQueryBuilder('aj')
85
            ->where('aj.alliance = :allianceId')
86
            ->andWhere('aj.is_diplomatic_permission = true')
87
            ->setParameter('allianceId', $allianceId)
88
            ->getQuery()
89
            ->getResult();
90
    }
91
92
    #[Override]
93
    public function getByAllianceAndTitle(int $allianceId, string $title): ?AllianceJob
94
    {
95
        return $this->createQueryBuilder('aj')
96
            ->where('aj.alliance = :allianceId')
97
            ->andWhere('aj.title = :title')
98
            ->setParameter('allianceId', $allianceId)
99
            ->setParameter('title', $title)
100
            ->getQuery()
101
            ->getOneOrNullResult();
102
    }
103
}
104