Passed
Pull Request — master (#2138)
by Janko
24:59 queued 14:00
created

SpacecraftFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 1
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