Passed
Pull Request — master (#2194)
by Janko
27:48 queued 20:18
created

PirateWrathRepository::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 10
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\PirateWrath;
10
use Stu\Orm\Entity\User;
11
12
/**
13
 * @extends EntityRepository<PirateWrath>
14
 *
15
 * @method PirateWrath[] findAll()
16
 */
17
final class PirateWrathRepository extends EntityRepository implements PirateWrathRepositoryInterface
18
{
19
    #[Override]
20
    public function save(PirateWrath $wrath): void
21
    {
22
        $em = $this->getEntityManager();
23
24
        $em->persist($wrath);
25
    }
26
27
    #[Override]
28
    public function delete(PirateWrath $wrath): void
29
    {
30
        $em = $this->getEntityManager();
31
        $em->remove($wrath);
32
        $em->flush();
33
    }
34
35
    #[Override]
36
    public function prototype(): PirateWrath
37
    {
38
        return new PirateWrath();
39
    }
40
41
    /**
42
     * @return PirateWrath[]
43
     */
44 1
    #[Override]
45
    public function getPirateWrathTop10(): array
46
    {
47 1
        return $this->getEntityManager()
48 1
            ->createQuery(
49 1
                sprintf(
50 1
                    'SELECT pw
51
            FROM %s pw
52 1
            ORDER BY pw.wrath DESC',
53 1
                    PirateWrath::class
54 1
                )
55 1
            )
56 1
            ->setMaxResults(10)
57 1
            ->getResult();
58
    }
59
60
    /**
61
     * @return PirateWrath[]
62
     */
63
    #[Override]
64
    public function getByUser(User $user): array
65
    {
66
        return $this->findBy(
67
            ['user' => $user]
68
        );
69
    }
70
}
71