Passed
Push — master ( dae2b6...a0c960 )
by Martijn
12:49
created

text()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Vanderlee\Comprehend\Library;
4
5
use Exception;
6
use Vanderlee\Comprehend\Parser\Structure\Choice;
7
use Vanderlee\Comprehend\Parser\Structure\Repeat;
8
use Vanderlee\Comprehend\Parser\Structure\Sequence;
9
use Vanderlee\Comprehend\Parser\Terminal\Char;
10
use Vanderlee\Comprehend\Parser\Terminal\Range;
11
use Vanderlee\Comprehend\Parser\Terminal\Regex;
12
use Vanderlee\Comprehend\Parser\Terminal\Set;
13
use Vanderlee\Comprehend\Parser\Terminal\Text;
14
15
function plus($parser)
16
{
17 8
    return Repeat::plus($parser);
18
}
19
20
function star($parser)
21
{
22 8
    return Repeat::star($parser);
23
}
24
25
function opt($parser)
26
{
27 8
    return Repeat::optional($parser);
28
}
29
30
function repeat($from, $to, $parser)
31
{
32 4
    return new Repeat($parser, $from, $to);
33
}
34
35
function s(...$parsers)
36
{
37 8
    return new Sequence(...$parsers);
38
}
39
40
function c(...$choices)
41
{
42 8
    return new Choice(...$choices);
43
}
44
45
function range($from, $to)
46
{
47 8
    return new Range($from, $to);
48
}
49
50
/**
51
 * @throws Exception
52
 */
53
function set(string $set)
54
{
55 8
    return new Set($set);
56
}
57
58
function regex(string $pattern)
59
{
60 8
    return new Regex($pattern);
61
}
62
63
function char($char)
64
{
65 8
    return new Char($char);
66
}
67
68
function text($text)
69
{
70 8
    return new Text($text);
71
}
72