Passed
Push — master ( 8a7749...5c0d1f )
by Romain
39s queued 10s
created

GamePlay::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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 2
    public function __construct(
50
        string $gameId,
51
        string $playerId,
52
        string $contextType,
53
        string $contextId,
54
        int $score,
55
        string $payload
56
    ) {
57 2
        $this->gameId = $gameId;
58 2
        $this->playerId = $playerId;
59 2
        $this->contextType = $contextType;
60 2
        $this->contextId = $contextId;
61 2
        $this->score = $score;
62 2
        $this->payload = $payload;
63 2
    }
64
65
    /**
66
     * @return string
67
     */
68 1
    public function getGameId(): string
69
    {
70 1
        return $this->gameId;
71
    }
72
73
    /**
74
     * @return string
75
     */
76 1
    public function getPlayerId(): string
77
    {
78 1
        return $this->playerId;
79
    }
80
81
    /**
82
     * @return string
83
     */
84 1
    public function getContextType(): string
85
    {
86 1
        return $this->contextType;
87
    }
88
89
    /**
90
     * @return string
91
     */
92 1
    public function getContextId(): string
93
    {
94 1
        return $this->contextId;
95
    }
96
97
    /**
98
     * @return int
99
     */
100 1
    public function getScore(): int
101
    {
102 1
        return $this->score;
103
    }
104
105
    /**
106
     * @return string
107
     */
108 1
    public function getPayload(): string
109
    {
110 1
        return $this->payload;
111
    }
112
113
    /**
114
     * @param array $callbackData
115
     *
116
     * @return \Kerox\Messenger\Model\Callback\GamePlay
117
     */
118 1
    public static function create(array $callbackData): self
119
    {
120 1
        return new self(
121 1
            $callbackData['game_id'],
122 1
            $callbackData['player_id'],
123 1
            $callbackData['context_type'],
124 1
            $callbackData['context_id'],
125 1
            $callbackData['score'],
126 1
            $callbackData['payload']
127
        );
128
    }
129
}
130