Test Failed
Push — dev ( d9ea74...46b33e )
by Nico
09:52
created

truncateAllEntities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 1
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\RpgPlotMemberArchiv;
9
use Stu\Orm\Entity\RpgPlotMemberArchivInterface;
10
11
/**
12
 * @extends EntityRepository<RpgPlotMemberArchiv>
13
 */
14
final class RpgPlotMemberArchivRepository extends EntityRepository implements RpgPlotMemberArchivRepositoryInterface
15
{
16
    public function getByPlotAndUser(int $plotId, int $userId): ?RpgPlotMemberArchivInterface
17
    {
18
        return $this->findOneBy([
19
            'plot_id' => $plotId,
20
            'user_id' => $userId
21
        ]);
22
    }
23
24
    public function prototype(): RpgPlotMemberArchivInterface
25
    {
26
        return new RpgPlotMemberArchivInterface();
27
    }
28
29
    public function save(RpgPlotMemberArchivInterface $rpgPlotMember): void
30
    {
31
        $em = $this->getEntityManager();
32
33
        $em->persist($rpgPlotMember);
34
    }
35
36
    public function delete(RpgPlotMemberArchivInterface $rpgPlotMember): void
37
    {
38
        $em = $this->getEntityManager();
39
40
        $em->remove($rpgPlotMember);
41
    }
42
43
    public function getByPlot(int $plotId): array
44
    {
45
        return $this->findBy([
46
            'plot_id' => $plotId
47
        ]);
48
    }
49
50
    public function truncateAllEntities(): void
51
    {
52
        $this->getEntityManager()->createQuery(
53
            sprintf(
54
                'DELETE FROM %s pm',
55
                RpgPlotMemberArchiv::class
56
            )
57
        )->execute();
58
    }
59
}
60