AbstractPlayerCommand::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
crap 1
1
<?php
2
3
namespace MiniGameApp\Command;
4
5
use League\Tactician\Plugins\NamedCommand\NamedCommand;
6
use MiniGame\Entity\MiniGameId;
7
use MiniGame\Entity\PlayerId;
8
use RemiSan\Context\Context;
9
use RemiSan\Context\ContextAware;
10
11
abstract class AbstractPlayerCommand implements NamedCommand, ContextAware
12
{
13
    /**
14
     * @var MiniGameId
15
     */
16
    protected $gameId;
17
18
    /**
19
     * @var PlayerId
20
     */
21
    protected $playerId;
22
23
    /**
24
     * @var Context
25
     */
26
    protected $context;
27
28
    /**
29
     * Init.
30
     *
31
     * @param MiniGameId $gameId
32
     * @param PlayerId   $playerId
33
     * @param Context    $context
34
     */
35 54
    protected function init(
36
        MiniGameId $gameId,
37
        PlayerId $playerId,
38
        Context $context = null
39
    ) {
40 54
        $this->gameId = $gameId;
41 54
        $this->playerId = $playerId;
42 54
        $this->context = $context;
43 54
    }
44
45
    /**
46
     * Returns the minigame id
47
     *
48
     * @return MiniGameId
49
     */
50 54
    public function getGameId()
51
    {
52 54
        return $this->gameId;
53
    }
54
55
    /**
56
     * Returns the player id
57
     *
58
     * @return PlayerId
59
     */
60 51
    public function getPlayerId()
61
    {
62 51
        return $this->playerId;
63
    }
64
65
    /**
66
     * Returns the command name
67
     *
68
     * @return string
69
     */
70
    abstract public function getCommandName();
71
72
    /**
73
     * Returns the context
74
     *
75
     * @return Context
76
     */
77 54
    public function getContext()
78
    {
79 54
        return $this->context;
80
    }
81
}
82