NotOperator::evaluate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Aleksandar Panic
4
 * @license http://www.apache.org/licenses/LICENSE-2.0
5
 * @since 1.0.0
6
 **/
7
8
namespace ArekX\ArrayExpression\Operators;
9
10
use ArekX\ArrayExpression\Interfaces\ValueParser;
11
12
/**
13
 * Class NotOperator
14
 * Operator for handling NOT function
15
 *
16
 * @package ArekX\ArrayExpression\Operators
17
 */
18
class NotOperator extends BaseGroupOperator
19
{
20
    /**
21
     * Evaluates one value.
22
     *
23
     * @param ValueParser $value Value to be evaluated
24
     * @return mixed Evaluation result
25
     */
26 4
    public function evaluate(ValueParser $value)
27
    {
28 4
        if (empty($this->operators[1])) {
29 4
            $this->assertIsExpression($this->config[1]);
30 4
            $this->operators[1] = $this->parser->parse($this->config[1]);
31
        }
32
33 4
        return !$this->operators[1]->evaluate($value);
34
    }
35
}