Code Duplication    Length = 56-56 lines in 2 locations

src/Prophecy/Argument/Token/InArrayToken.php 1 location

@@ 19-74 (lines=56) @@
16
 *
17
 * @author Vinícius Alonso <[email protected]>
18
 */
19
class InArrayToken implements TokenInterface
20
{
21
    private $token = array();
22
    private $strict;
23
24
    /**
25
     * @param array $arguments tokens
26
     * @param bool $strict
27
     */
28
    public function __construct(array $arguments, $strict = true)
29
    {
30
        $this->token = $arguments;
31
        $this->strict = $strict;
32
    }
33
34
    /**
35
     * Return scores 8 score if argument is in array.
36
     *
37
     * @param $argument
38
     *
39
     * @return bool|int
40
     */
41
    public function scoreArgument($argument)
42
    {
43
        if (count($this->token) === 0) {
44
            return false;
45
        }
46
47
        if (\in_array($argument, $this->token, $this->strict)) {
48
            return 8;
49
        }
50
51
        return false;
52
    }
53
54
    /**
55
     * Returns false.
56
     *
57
     * @return boolean
58
     */
59
    public function isLast()
60
    {
61
        return false;
62
    }
63
64
    /**
65
     * Returns string representation for token.
66
     *
67
     * @return string
68
     */
69
    public function __toString()
70
    {
71
        $arrayAsString = implode(', ', $this->token);
72
        return "[{$arrayAsString}]";
73
    }
74
}
75

src/Prophecy/Argument/Token/NotInArrayToken.php 1 location

@@ 19-74 (lines=56) @@
16
 *
17
 * @author Vinícius Alonso <[email protected]>
18
 */
19
class NotInArrayToken implements TokenInterface
20
{
21
    private $token = array();
22
    private $strict;
23
24
    /**
25
     * @param array $arguments tokens
26
     * @param bool $strict
27
     */
28
    public function __construct(array $arguments, $strict = true)
29
    {
30
        $this->token = $arguments;
31
        $this->strict = $strict;
32
    }
33
34
    /**
35
     * Return scores 8 score if argument is in array.
36
     *
37
     * @param $argument
38
     *
39
     * @return bool|int
40
     */
41
    public function scoreArgument($argument)
42
    {
43
        if (count($this->token) === 0) {
44
            return false;
45
        }
46
47
        if (!\in_array($argument, $this->token, $this->strict)) {
48
            return 8;
49
        }
50
51
        return false;
52
    }
53
54
    /**
55
     * Returns false.
56
     *
57
     * @return boolean
58
     */
59
    public function isLast()
60
    {
61
        return false;
62
    }
63
64
    /**
65
     * Returns string representation for token.
66
     *
67
     * @return string
68
     */
69
    public function __toString()
70
    {
71
        $arrayAsString = implode(', ', $this->token);
72
        return "[{$arrayAsString}]";
73
    }
74
}
75
76