Passed
Push — master ( cc891d...b53f20 )
by Nico
11:42
created

RefactorRunner::removeBuildplanDuplicates()   B

Complexity

Conditions 7
Paths 4

Size

Total Lines 33
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 0
Metric Value
cc 7
eloc 22
nc 4
nop 0
dl 0
loc 33
ccs 0
cts 21
cp 0
crap 56
rs 8.6346
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Refactor;
6
7
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperFactoryInterface;
8
use Stu\Orm\Repository\SpacecraftRepositoryInterface;
9
10
final class RefactorRunner
11
{
12 1
    public function __construct(
13
        private SpacecraftRepositoryInterface $spacecraftRepository,
14
        private SpacecraftWrapperFactoryInterface $spacecraftWrapperFactory,
15 1
    ) {}
16
17
    public function refactor(): void
18
    {
19
        foreach ($this->spacecraftRepository->findAll() as $spacecraft) {
20
            $wrapper = $this->spacecraftWrapperFactory->wrapSpacecraft($spacecraft);
21
22
            $shieldSystemData = $wrapper->getShieldSystemData();
23
            if ($shieldSystemData !== null) {
24
                $shieldSystemData
25
                    ->setShieldRegenerationTimer($spacecraft->getShieldRegenerationTimer())
26
                    ->update();
27
            }
28
29
            $shieldSystemData = $wrapper->getLssSystemData();
30
            if ($shieldSystemData !== null) {
31
                $shieldSystemData
32
                    ->setSensorRange($spacecraft->getSensorRange())
33
                    ->update();
34
            }
35
        }
36
    }
37
}
38