Passed
Pull Request — master (#2138)
by Janko
39:06 queued 27:26
created

SpacecraftFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Stu\Module\Spacecraft\Lib\Creation;
4
5
use Stu\Component\Spacecraft\SpacecraftTypeEnum;
6
use Stu\Orm\Entity\Ship;
7
use Stu\Orm\Entity\SpacecraftCondition;
8
use Stu\Orm\Entity\SpacecraftRumpInterface;
9
use Stu\Orm\Entity\SpacecraftInterface;
10
use Stu\Orm\Entity\Station;
11
use Stu\Orm\Entity\TholianWeb;
12
13
class SpacecraftFactory implements SpacecraftFactoryInterface
14
{
15 3
    public function create(SpacecraftRumpInterface $rump): SpacecraftInterface
16
    {
17 3
        $spacecraft = match ($rump->getShipRumpCategory()->getType()) {
18 3
            SpacecraftTypeEnum::SHIP => new Ship(),
19 2
            SpacecraftTypeEnum::STATION => new Station(),
20 1
            SpacecraftTypeEnum::THOLIAN_WEB => new TholianWeb()
21 3
        };
22
23 3
        $spacecraft->setCondition(new SpacecraftCondition($spacecraft));
24
25 3
        return $spacecraft;
26
    }
27
}
28