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

VisitEvent::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 9
ccs 0
cts 6
cp 0
crap 2
rs 10
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