| Total Complexity | 8 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class ReloadMinimalEps implements ReloadMinimalEpsInterface |
||
| 9 | { |
||
| 10 | public function reload(FleetWrapperInterface $fleetWrapper, int $minimalPercentage = 20): void |
||
| 11 | { |
||
| 12 | foreach ($fleetWrapper->getShipWrappers() as $wrapper) { |
||
| 13 | $this->reloadEps($wrapper, $minimalPercentage); |
||
| 14 | $this->reloadWarpdrive($wrapper, $minimalPercentage); |
||
| 15 | } |
||
| 16 | } |
||
| 17 | |||
| 18 | private function reloadEps(ShipWrapperInterface $wrapper, int $minimalPercentage): void |
||
| 19 | { |
||
| 20 | $epsSystem = $wrapper->getEpsSystemData(); |
||
| 21 | |||
| 22 | if ( |
||
| 23 | $epsSystem !== null |
||
| 24 | && $epsSystem->getEpsPercentage() < $minimalPercentage |
||
| 25 | ) { |
||
| 26 | $epsSystem->setEps((int)($epsSystem->getMaxEps() * $minimalPercentage / 100))->update(); |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | private function reloadWarpdrive(ShipWrapperInterface $wrapper, int $minimalPercentage): void |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 |