StringContainsToken::getValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Prophecy.
5
 * (c) Konstantin Kudryashov <[email protected]>
6
 *     Marcello Duarte <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Prophecy\Argument\Token;
13
14
/**
15
 * String contains token.
16
 *
17
 * @author Peter Mitchell <[email protected]>
18
 */
19
class StringContainsToken implements TokenInterface
20
{
21
    private $value;
22
23
    /**
24
     * Initializes token.
25
     *
26
     * @param string $value
27
     */
28
    public function __construct($value)
29
    {
30
        $this->value = $value;
31
    }
32
33
    public function scoreArgument($argument)
34
    {
35
        return is_string($argument) && strpos($argument, $this->value) !== false ? 6 : false;
36
    }
37
38
    /**
39
     * Returns preset value against which token checks arguments.
40
     *
41
     * @return mixed
42
     */
43
    public function getValue()
44
    {
45
        return $this->value;
46
    }
47
48
    /**
49
     * Returns false.
50
     *
51
     * @return bool
52
     */
53
    public function isLast()
54
    {
55
        return false;
56
    }
57
58
    /**
59
     * Returns string representation for token.
60
     *
61
     * @return string
62
     */
63
    public function __toString()
64
    {
65
        return sprintf('contains("%s")', $this->value);
66
    }
67
}
68