Completed
Push — master ( c80620...0cd8d9 )
by Martijn
03:25
created

Nothing   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
namespace Vanderlee\Comprehend\Parser\Terminal;
4
5
use Vanderlee\Comprehend\Core\Context;
6
use Vanderlee\Comprehend\Parser\Parser;
7
8
/**
9
 * Matches always, with length zero.
10
 * This serves as a placeholder for badly written BNF specifications and should not be used in normal situations.
11
 * Do NOT use this within repetitions!
12
 *
13
 * @author Martijn
14
 */
15
class Nothing extends Parser
16
{
17
18
    protected function parse(&$input, $offset, Context $context)
19
    {
20
        return $this->makeMatch($offset <= mb_strlen($input), $input, 0);
21
    }
22
23
    public function __toString()
24
    {
25
        return '0.';
26
    }
27
28
}
29