StupidPlayer::play()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace GameDomain\Player\Players;
4
5
use GameDomain\Player\PlayerInterface;
6
use GameDomain\Round\Step\Answer;
7
use GameDomain\Round\Step\Step;
8
use GameDomain\Rule\AbstractRulesSet;
9
10
/**
11
 * Stupid Player : this player never gives a correct answer.
12
 */
13
class StupidPlayer implements PlayerInterface
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18
    public function play(AbstractRulesSet $gameRules, Step $step)
19
    {
20
        $validAnswer = $gameRules->generateValidAnswer($step->getRawValue());
21
22
        // Obfuscate the answer so that it's never correct
23
        return new Answer(md5($validAnswer->getRawValue()));
24
    }
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    public function __toString()
30
    {
31
        return 'Stupid';
32
    }
33
}
34