Passed
Pull Request — master (#1806)
by Nico
53:13 queued 28:49
created

PirateWrathRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 20
c 1
b 0
f 1
dl 0
loc 47
ccs 0
cts 26
cp 0
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A prototype() 0 3 1
A truncateAllEntries() 0 8 1
A save() 0 5 1
A getPirateWrathTop10() 0 13 1
A delete() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Repository;
6
7
use Doctrine\ORM\EntityRepository;
8
use Stu\Orm\Entity\PirateWrath;
9
use Stu\Orm\Entity\PirateWrathInterface;
10
use Stu\Orm\Entity\User;
11
12
/**
13
 * @extends EntityRepository<PirateWrath>
14
 *
15
 * @method PirateWrathInterface[] findAll()
16
 */
17
final class PirateWrathRepository extends EntityRepository implements PirateWrathRepositoryInterface
18
{
19
    public function save(PirateWrathInterface $wrath): void
20
    {
21
        $em = $this->getEntityManager();
22
23
        $em->persist($wrath);
24
    }
25
26
    public function delete(PirateWrathInterface $wrath): void
27
    {
28
        $em = $this->getEntityManager();
29
30
        $em->remove($wrath);
31
    }
32
33
    public function prototype(): PirateWrathInterface
34
    {
35
        return new PirateWrath();
36
    }
37
38
    public function truncateAllEntries(): void
39
    {
40
        $this->getEntityManager()->createQuery(
41
            sprintf(
42
                'DELETE FROM %s pw',
43
                PirateWrath::class
44
            )
45
        )->execute();
46
    }
47
48
    /**
49
     * @return PirateWrathInterface[]
50
     */
51
    public function getPirateWrathTop10(): array
52
    {
53
        return $this->getEntityManager()
54
            ->createQuery(
55
                sprintf(
56
                    'SELECT pw
57
            FROM %s pw
58
            ORDER BY pw.wrath DESC',
59
                    PirateWrath::class
60
                )
61
            )
62
            ->setMaxResults(10)
63
            ->getResult();
64
    }
65
}
66