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

PirateWrathRepository::truncateAllEntries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
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