Passed
Push — dev ( f1dc2a...210bba )
by Nico
08:46
created

WeaponShieldRepository   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 38
ccs 0
cts 19
cp 0
rs 10
c 2
b 0
f 0
wmc 6

5 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
A getFactionByModule() 0 7 2
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
    public function getFactionByModule($moduleid): ?WeaponShieldInterface
47
    {
48
        for ($index = 1; $index <= 5; $index++) {
0 ignored issues
show
Unused Code introduced by
PostIncNode is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
49
            return $this->findOneBy(
50
                [
51
                    'faction_id' => $index,
52
                    'module_id' => $moduleid
53
                ]
54
            );
55
        }
56
    }
57
}