Passed
Push — master ( 77a570...adeb98 )
by Nico
26:43
created

FinishShipRetrofitJobs::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 3
dl 0
loc 1
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Tick\Process;
6
7
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Stu\Module\Message\Lib\PrivateMessageFolderTypeEnum;
9
use Stu\Module\Message\Lib\PrivateMessageSenderInterface;
10
use Stu\Module\PlayerSetting\Lib\UserEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Module\PlayerSetting\Lib\UserEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Stu\Component\Ship\ShipStateEnum;
12
use Stu\Module\Ship\Lib\ShipRetrofitInterface;
13
use Stu\Orm\Repository\ColonyShipQueueRepositoryInterface;
14
use Stu\Orm\Repository\ShipRepositoryInterface;
15
16
final class FinishShipRetrofitJobs implements ProcessTickHandlerInterface
17
{
18
    public function __construct(private ShipRetrofitInterface $shipRetrofit, private ColonyShipQueueRepositoryInterface $colonyShipQueueRepository, private ShipRepositoryInterface $shipRepository) {}
19
20
    #[Override]
21
    public function work(): void
22
    {
23
        $queue = $this->colonyShipQueueRepository->getFinishedJobs();
24
        foreach ($queue as $obj) {
25
            if ($obj->getMode() == 2) {
26
27
                $colony = $obj->getColony();
28
29
                $newbuildplan = $obj->getShipBuildplan();
30
                $ship = $obj->getShip();
31
32
                if ($ship == null) {
33
                    return;
34
                }
35
36
                $this->shipRetrofit->updateBy(
37
                    $ship,
38
                    $newbuildplan,
39
                    $colony
40
                );
41
                $this->colonyShipQueueRepository->delete($obj);
42
43
                $ship->setState(ShipStateEnum::SHIP_STATE_NONE);
44
45
                $this->shipRepository->save($ship);
46
            }
47
        }
48
    }
49
}