Test Failed
Push — main ( 640dfc...f14cf5 )
by Alex
04:51
created

ItemRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Repository\Game;
4
5
use App\Entity\Game\Item;
6
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
7
use Doctrine\Persistence\ManagerRegistry;
8
9
/**
10
 * @extends ServiceEntityRepository<Item>
11
 *
12
 * @method Item|null find($id, $lockMode = null, $lockVersion = null)
13
 * @method Item|null findOneBy(array $criteria, array $orderBy = null)
14
 * @method Item[]    findAll()
15
 * @method Item[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
16
 */
17
class ItemRepository extends ServiceEntityRepository
18
{
19 4
    public function __construct(ManagerRegistry $registry)
20
    {
21 4
        parent::__construct($registry, Item::class);
22
    }
23
24
    /** @SuppressWarnings(PHPMD.BooleanArgumentFlag) */
25
    public function save(Item $entity, bool $flush = false): void
26
    {
27
        $this->getEntityManager()->persist($entity);
28
29
        if ($flush) {
30
            $this->getEntityManager()->flush();
31
        }
32
    }
33
34
    /** @SuppressWarnings(PHPMD.BooleanArgumentFlag) */
35
    public function remove(Item $entity, bool $flush = false): void
36
    {
37
        $this->getEntityManager()->remove($entity);
38
39
        if ($flush) {
40
            $this->getEntityManager()->flush();
41
        }
42
    }
43
}
44