StupidPlayer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 3
Metric Value
wmc 2
cbo 3
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A play() 0 7 1
A __toString() 0 4 1
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