Passed
Pull Request — master (#1801)
by Nico
23:50
created

PirateWrathRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
dl 0
loc 29
ccs 0
cts 15
cp 0
rs 10
c 1
b 0
f 1
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prototype() 0 3 1
A save() 0 5 1
A delete() 0 5 1
A truncateAllEntries() 0 8 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
11
/**
12
 * @extends EntityRepository<PirateWrath>
13
 * 
14
 * @method PirateWrathInterface[] findAll()
15
 */
16
final class PirateWrathRepository extends EntityRepository implements PirateWrathRepositoryInterface
17
{
18
    public function save(PirateWrathInterface $wrath): void
19
    {
20
        $em = $this->getEntityManager();
21
22
        $em->persist($wrath);
23
    }
24
25
    public function delete(PirateWrathInterface $wrath): void
26
    {
27
        $em = $this->getEntityManager();
28
29
        $em->remove($wrath);
30
    }
31
32
    public function prototype(): PirateWrathInterface
33
    {
34
        return new PirateWrath();
35
    }
36
37
    public function truncateAllEntries(): void
38
    {
39
        $this->getEntityManager()->createQuery(
40
            sprintf(
41
                'DELETE FROM %s pw',
42
                PirateWrath::class
43
            )
44
        )->execute();
45
    }
46
}
47