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

NPCLogRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A prototype() 0 3 1
A truncateAllEntities() 0 8 1
A getRecent() 0 6 1
A save() 0 5 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\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