Not::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Vanderlee\Comprehend\Parser\Structure;
4
5
use Vanderlee\Comprehend\Core\ArgumentsTrait;
6
use Vanderlee\Comprehend\Core\Context;
7
use Vanderlee\Comprehend\Match\Success;
8
use Vanderlee\Comprehend\Parser\Parser;
9
10
/**
11
 * Description of NotParser.
12
 *
13
 * @author Martijn
14
 */
15
class Not extends Parser
16
{
17
    use ArgumentsTrait;
18
19
    private $parser;
20
21 1
    public function __construct($parser)
22
    {
23 1
        $this->parser = self::getArgument($parser);
24 1
    }
25
26 6
    protected function parse(&$input, $offset, Context $context)
27
    {
28 6
        $match = $this->parser->parse($input, $offset, $context);
29
30 6
        return ($match instanceof Success)
31 2
            ? $this->failure($input, $offset, $match->length)
32 6
            : $this->success($input, $offset);
33
    }
34
35 6
    public function __toString()
36
    {
37 6
        return '!' . $this->parser;
38
    }
39
}
40