LogicalNotToken   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 55
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A scoreArgument() 0 4 2
A isLast() 0 4 1
A getOriginatingToken() 0 4 1
A __toString() 0 4 1
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
 * Logical NOT token.
16
 *
17
 * @author Boris Mikhaylov <[email protected]>
18
 */
19
class LogicalNotToken implements TokenInterface
20
{
21
    /** @var \Prophecy\Argument\Token\TokenInterface  */
22
    private $token;
23
24
    /**
25
     * @param mixed $value exact value or token
26
     */
27
    public function __construct($value)
28
    {
29
        $this->token = $value instanceof TokenInterface? $value : new ExactValueToken($value);
30
    }
31
32
    /**
33
     * Scores 4 when preset token does not match the argument.
34
     *
35
     * @param $argument
36
     *
37
     * @return bool|int
38
     */
39
    public function scoreArgument($argument)
40
    {
41
        return false === $this->token->scoreArgument($argument) ? 4 : false;
42
    }
43
44
    /**
45
     * Returns true if preset token is last.
46
     *
47
     * @return bool|int
48
     */
49
    public function isLast()
50
    {
51
        return $this->token->isLast();
52
    }
53
54
    /**
55
     * Returns originating token.
56
     *
57
     * @return TokenInterface
58
     */
59
    public function getOriginatingToken()
60
    {
61
        return $this->token;
62
    }
63
64
    /**
65
     * Returns string representation for token.
66
     *
67
     * @return string
68
     */
69
    public function __toString()
70
    {
71
        return sprintf('not(%s)', $this->token);
72
    }
73
}
74