Passed
Pull Request — master (#1969)
by Janko
22:34 queued 10:03
created

ShipCreator::addSpecialSystems()   C

Complexity

Conditions 16
Paths 16

Size

Total Lines 48
Code Lines 45

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 272

Importance

Changes 0
Metric Value
cc 16
eloc 45
nc 16
nop 2
dl 0
loc 48
ccs 0
cts 46
cp 0
crap 272
rs 5.5666
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\Lib;
6
7
use Stu\Module\Spacecraft\Lib\Creation\ShipCreationConfig;
8
use Stu\Module\Spacecraft\Lib\Creation\SpacecraftConfiguratorInterface;
9
use Stu\Module\Spacecraft\Lib\Creation\SpacecraftCreatorInterface;
10
use Stu\Orm\Repository\SpacecraftBuildplanRepositoryInterface;
11
12
final class ShipCreator implements ShipCreatorInterface
13
{
14
    /** @param SpacecraftCreatorInterface<ShipWrapperInterface> $spacecraftCreator */
15 1
    public function __construct(
16
        private SpacecraftBuildplanRepositoryInterface $buildplanRepository,
17
        private SpacecraftCreatorInterface $spacecraftCreator
18 1
    ) {}
19
20
    public function createBy(
21
        int $userId,
22
        int $rumpId,
23
        int $buildplanId
24
    ): SpacecraftConfiguratorInterface {
25
26
        $configurator = $this->spacecraftCreator->createBy(
27
            $userId,
28
            $rumpId,
29
            $buildplanId,
30
            new ShipCreationConfig($this->buildplanRepository, $buildplanId)
31
        );
32
33
        return $configurator;
34
    }
35
}
36