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

DialogEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 22
ccs 4
cts 8
cp 0.5
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
A __construct() 0 9 1
A getSubject() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Event;
6
7
use AardsGerds\Game\Dialog\DialogOption;
8
use AardsGerds\Game\Entity\Entity;
9
use AardsGerds\Game\Player\Player;
10
use AardsGerds\Game\Player\PlayerAction;
11
12
abstract class DialogEvent extends Event
13
{
14 1
    public function __construct(
15
        Context $context,
16
        DecisionCollection $decisionCollection,
17
        protected Entity $subject,
18
        protected DialogOption $dialogOption,
19
    ) {
20 1
        parent::__construct(
21 1
            $context,
22
            $decisionCollection,
23
        );
24 1
    }
25
26
    public function __invoke(Player $player, PlayerAction $playerAction): Decision
27
    {
28
        return $playerAction->askForDecision((string) $this->context, $this->decisionCollection);
29
    }
30
31
    public function getSubject(): Entity
32
    {
33
        return $this->subject;
34
    }
35
}
36