Test Failed
Pull Request — master (#1775)
by Nico
26:52
created

NPCLogRepository::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
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\NPCLog;
9
use Stu\Orm\Entity\NPCLogInterface;
10
11
12
/**
13
 * @extends EntityRepository<NPCLog>
14
 */
15
final class NPCLogRepository extends EntityRepository implements NPCLogRepositoryInterface
16
{
17
    public function getRecent(): array
18
    {
19
        return $this->findBy(
20
            [],
21
            ['id' => 'desc'],
22
            10
23
        );
24
    }
25
26
    public function prototype(): NPCLogInterface
27
    {
28
        return new NPCLog();
29
    }
30
31
    public function save(NPCLogInterface $npclog): void
32
    {
33
        $em = $this->getEntityManager();
34
35
        $em->persist($npclog);
36
    }
37
38
    public function delete(NPCLogInterface $npclog): void
39
    {
40
        $em = $this->getEntityManager();
41
42
        $em->remove($npclog);
43
    }
44
45
    public function truncateAllEntities(): void
46
    {
47
        $this->getEntityManager()->createQuery(
48
            sprintf(
49
                'DELETE FROM %s n',
50
                NPCLog::class
51
            )
52
        )->execute();
53
    }
54
}
55