Completed
Push — master ( 719dbc...a8fbe3 )
by Rémi
03:51
created

HangmanPlayerWinEvent::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Hangman\Event;
4
5
use Hangman\Event\Util\HangmanResultEvent;
6
use Hangman\Result\HangmanWon;
7
use MiniGame\Entity\MiniGameId;
8
use MiniGame\Entity\PlayerId;
9
use MiniGame\Result\AllPlayersResult;
10
11
class HangmanPlayerWinEvent extends HangmanResultEvent implements AllPlayersResult, HangmanWon
12
{
13
    /**
14
     * @var string
15
     */
16
    const NAME = 'hangman.player.win';
17
18
    /**
19
     * @var string
20
     */
21
    private $word;
22
23
    /**
24
     * Constructor
25
     *
26
     * @param MiniGameId $gameId
27
     * @param PlayerId   $playerId
28
     * @param array      $playedLetters
29
     * @param int        $remainingLives
30
     * @param string     $word
31
     */
32 9
    public function __construct(
33
        MiniGameId $gameId,
34
        PlayerId $playerId,
35
        array $playedLetters,
36
        $remainingLives,
37
        $word
38
    ) {
39 9
        parent::__construct(self::NAME, $gameId, $playerId, $playedLetters, $remainingLives);
40 9
        $this->word = $word;
41 9
    }
42
43
    /**
44
     * @return string
45
     */
46 3
    public function getWord()
47
    {
48 3
        return $this->word;
49
    }
50
51
    /**
52
     * @return string
53
     */
54 6
    public function getSolution()
55
    {
56 6
        return $this->word;
57
    }
58
59
    /**
60
     * @return string
61
     */
62 3
    public function getAsMessage()
63
    {
64 3
        return sprintf('Congratulations! The word was %s.', $this->getWord());
65
    }
66
}
67