Passed
Push — master ( 888025...8927c7 )
by Paweł
03:33
created

VisitEvent   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 40%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 21
ccs 4
cts 10
cp 0.4
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A __invoke() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Event;
6
7
use AardsGerds\Game\Player\Player;
8
use AardsGerds\Game\Player\PlayerAction;
9
10
abstract class VisitEvent extends Event
11
{
12 1
    public function __construct(
13
        Context $context,
14
        DecisionCollection $decisionCollection,
15
    ) {
16 1
        parent::__construct(
17 1
            $context,
18
            $decisionCollection,
19
        );
20 1
    }
21
22
    public function __invoke(Player $player, PlayerAction $playerAction): Decision
23
    {
24
        $player->setCheckpoint($this);
25
        $playerAction->savePlayerState($player);
26
27
        $playerAction->introduce((string) $this->context->getLocation());
28
        $playerAction->tell((string) $this->context);
29
30
        return $playerAction->askForDecision('Where do you want to go?', $this->decisionCollection);
31
    }
32
}
33