Passed
Push — master ( 8927c7...af53cd )
by Paweł
03:06
created

VisitEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 26
ccs 4
cts 12
cp 0.3333
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

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