Passed
Pull Request — master (#1686)
by Nico
31:24
created

RefactorReactorRunner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 27
ccs 0
cts 12
cp 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A refactor() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Ship\Refactor;
6
7
use Stu\Module\Ship\Lib\ShipWrapperFactoryInterface;
8
use Stu\Orm\Repository\ShipRepositoryInterface;
9
10
final class RefactorReactorRunner
11
{
12
    private ShipRepositoryInterface $shipRepository;
13
14
    private ShipWrapperFactoryInterface $shipWrapperFactory;
15
16
    public function __construct(
17
        ShipRepositoryInterface $shipRepository,
18
        ShipWrapperFactoryInterface $shipWrapperFactory
19
    ) {
20
        $this->shipRepository = $shipRepository;
21
        $this->shipWrapperFactory = $shipWrapperFactory;
22
    }
23
24
    public function refactor(): void
25
    {
26
        foreach ($this->shipRepository->findAll() as $ship) {
27
            $wrapper = $this->shipWrapperFactory->wrapShip($ship);
28
29
            $reactorWrapper = $wrapper->getReactorWrapper();
30
            if ($reactorWrapper === null) {
31
                continue;
32
            }
33
34
            $reactorWrapper
35
                ->setOutput($ship->getTheoreticalReactorOutput())
36
                ->setLoad($ship->getReactorLoad());
37
        }
38
    }
39
}
40