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

WeaponShieldRepository::getFactionByModule()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 6
rs 10
c 1
b 0
f 0
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
}