Completed
Push — master ( 3fb39c...d85d4f )
by Romain
10s
created

GamePlay::getContextId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Callback;
6
7
class GamePlay
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $gameId;
13
14
    /**
15
     * @var string
16
     */
17
    protected $playerId;
18
19
    /**
20
     * @var string
21
     */
22
    protected $contextType;
23
24
    /**
25
     * @var string
26
     */
27
    protected $contextId;
28
29
    /**
30
     * @var int
31
     */
32
    protected $score;
33
34
    /**
35
     * @var string
36
     */
37
    protected $payload;
38
39
    /**
40
     * GamePlay constructor.
41
     *
42
     * @param string $gameId
43
     * @param string $playerId
44
     * @param string $contextType
45
     * @param string $contextId
46
     * @param int    $score
47
     * @param string $payload
48
     */
49
    public function __construct(
50
        string $gameId,
51
        string $playerId,
52
        string $contextType,
53
        string $contextId,
54
        int $score,
55
        string $payload
56
    ) {
57
        $this->gameId = $gameId;
58
        $this->playerId = $playerId;
59
        $this->contextType = $contextType;
60
        $this->contextId = $contextId;
61
        $this->score = $score;
62
        $this->payload = $payload;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getGameId(): string
69
    {
70
        return $this->gameId;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getPlayerId(): string
77
    {
78
        return $this->playerId;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getContextType(): string
85
    {
86
        return $this->contextType;
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getContextId(): string
93
    {
94
        return $this->contextId;
95
    }
96
97
    /**
98
     * @return int
99
     */
100
    public function getScore(): int
101
    {
102
        return $this->score;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function getPayload(): string
109
    {
110
        return $this->payload;
111
    }
112
113
    /**
114
     * @param array $callbackData
115
     *
116
     * @return \Kerox\Messenger\Model\Callback\GamePlay
117
     */
118
    public static function create(array $callbackData): self
119
    {
120
        return new self(
121
            $callbackData['game_id'],
122
            $callbackData['player_id'],
123
            $callbackData['context_type'],
124
            $callbackData['context_id'],
125
            $callbackData['score'],
126
            $callbackData['payload']
127
        );
128
    }
129
}
130