Passed
Pull Request — master (#1821)
by Nico
52:02 queued 25:23
created

BattlePartyFactory::createIncomingBattleParty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Stu\Module\Ship\Lib\Battle\Party;
4
5
use Doctrine\Common\Collections\Collection;
6
use Stu\Module\Ship\Lib\FleetWrapperInterface;
7
use Stu\Module\Ship\Lib\ShipWrapperFactoryInterface;
8
use Stu\Module\Ship\Lib\ShipWrapperInterface;
9
use Stu\Orm\Entity\ShipInterface;
10
use Stu\Orm\Repository\ShipRepositoryInterface;
11
12
class BattlePartyFactory implements BattlePartyFactoryInterface
13
{
14
    public function __construct(
15
        private ShipRepositoryInterface $shipRepository,
16
        private ShipWrapperFactoryInterface $shipWrapperFactory
17
    ) {
18
    }
19
20
    public function createAlertStateBattleParty(
21
        ShipWrapperInterface $leaderWrapper
22
    ): AlertStateBattleParty {
23
        return new AlertStateBattleParty($leaderWrapper);
24
    }
25
26
    public function createIncomingBattleParty(
27
        ShipWrapperInterface $leaderWrapper
28
    ): IncomingBattleParty {
29
        return new IncomingBattleParty($leaderWrapper);
30
    }
31
32
    public function createRoundBasedBattleParty(
33
        BattlePartyInterface $battleParty
34
    ): RoundBasedBattleParty {
35
        return new RoundBasedBattleParty($battleParty, $this->shipRepository);
36
    }
37
38
    public function createAttackingBattleParty(
39
        ShipWrapperInterface|FleetWrapperInterface $wrapper
40
    ): AttackingBattleParty {
41
        return new AttackingBattleParty($wrapper);
42
    }
43
44
    public function createAttackedBattleParty(
45
        ShipWrapperInterface $wrapper
46
    ): AttackedBattleParty {
47
        return new AttackedBattleParty($wrapper);
48
    }
49
50
    public function createSingletonBattleParty(
51
        ShipWrapperInterface $wrapper
52
    ): SingletonBattleParty {
53
        return new SingletonBattleParty($wrapper);
54
    }
55
56
    public function createMixedBattleParty(
57
        Collection $wrappers
58
    ): MixedBattleParty {
59
        return new MixedBattleParty($wrappers);
60
    }
61
62
    public function createColonyDefendingBattleParty(
63
        ShipInterface $leader
64
    ): ColonyDefendingBattleParty {
65
        return new ColonyDefendingBattleParty(
66
            $this->shipWrapperFactory->wrapShip($leader)
67
        );
68
    }
69
}
70