Space   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A parse() 0 7 1
A __toString() 0 3 1
1
<?php
2
3
namespace Vanderlee\Comprehend\Directive;
4
5
use Vanderlee\Comprehend\Core\ArgumentsTrait;
6
use Vanderlee\Comprehend\Core\Context;
7
use Vanderlee\Comprehend\Parser\Parser;
8
9
/**
10
 * Description of LexemeDirective.
11
 *
12
 * @author Martijn
13
 */
14
class Space extends Parser
15
{
16
    use ArgumentsTrait;
17
18
    /**
19
     * @var null|Parser
20
     */
21
    private $spacer;
22
23
    /**
24
     * @var null|Parser
25
     */
26
    private $parser;
27
28
    /**
29
     * Set (or disable) a spacer for the parser.
30
     *
31
     * @param Parser|string|int|bool|null $spacer
32
     * @param Parser|string|int $parser
33
     */
34 2
    public function __construct($spacer, $parser)
35
    {
36 2
        $this->spacer = $spacer === null
37 1
            ? null
38 1
            : self::getArgument($spacer);
39 2
        $this->parser = self::getArgument($parser);
40 2
    }
41
42 23
    protected function parse(&$input, $offset, Context $context)
43
    {
44 23
        $context->pushSpacer($this->spacer);
45 23
        $match = $this->parser->parse($input, $offset, $context);
0 ignored issues
show
Bug introduced by
The method parse() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        /** @scrutinizer ignore-call */ 
46
        $match = $this->parser->parse($input, $offset, $context);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46 23
        $context->popSpacer();
47
48 23
        return $match;
49
    }
50
51 23
    public function __toString()
52
    {
53 23
        return (string)$this->parser;
54
    }
55
}
56