Passed
Push — dev ( 02e99e...928e2e )
by Nico
12:03
created

WeaponShieldRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 12
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prototype() 0 3 1
A delete() 0 5 1
A save() 0 5 1
A getByModuleAndWeapon() 0 7 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\WeaponShieldInterface;
9
use Stu\Orm\Entity\WeaponShield;
10
11
12
/**
13
 * @extends EntityRepository<WeaponShield>
14
 */
15
final class WeaponShieldRepository extends EntityRepository implements WeaponShieldRepositoryInterface
16
{
17
    public function prototype(): WeaponShieldInterface
18
    {
19
        return new WeaponShield();
20
    }
21
22
    public function save(WeaponShieldInterface $weaponshield): void
23
    {
24
        $em = $this->getEntityManager();
25
26
        $em->persist($weaponshield);
27
    }
28
29
    public function delete(WeaponShieldInterface $weaponshield): void
30
    {
31
        $em = $this->getEntityManager();
32
33
        $em->remove($weaponshield);
34
    }
35
36
    public function getByModuleAndWeapon(
37
        int $moduleId,
38
        int $weaponId
39
    ): ?WeaponShieldInterface {
40
        return $this->findOneBy([
41
            'module_id' => $moduleId,
42
            'weapon_id' => $weaponId
43
        ]);
44
    }
45
}
46