Not   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __toString() 0 3 1
A parse() 0 7 2
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