PatternSpec   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 8
c 4
b 0
f 1
lcom 0
cbo 1
dl 0
loc 42
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_should_be_castable_to_string() 0 4 1
A it_should_assemble_right_pattern_with_any() 0 4 1
A it_should_assemble_right_pattern_with_digit() 0 4 1
A it_should_assemble_right_pattern_with_literal() 0 4 1
A it_should_assemble_right_pattern_with_literals() 0 4 1
A it_should_assemble_right_pattern_with_range() 0 4 1
A it_should_assemble_right_pattern_with_repetition() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Greppy package.
5
 *
6
 * (c) Daniel Ribeiro <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Relax\Greppy;
13
14
use Prophecy\Argument;
15
use PhpSpec\ObjectBehavior;
16
17
class PatternSpec extends ObjectBehavior
18
{
19
    function it_is_initializable()
20
    {
21
        $this->shouldHaveType('Relax\Greppy\Pattern');
22
    }
23
    
24
    function it_should_be_castable_to_string()
25
    {
26
        $this->any()->digit()->literal("c", "m", "f")->__toString()->shouldReturn("/.\d[cmf]/");
27
    }
28
    
29
    function it_should_assemble_right_pattern_with_any()
30
    {
31
        $this->any()->__toString()->shouldReturn('/./');
32
    }
33
34
    function it_should_assemble_right_pattern_with_digit()
35
    {
36
        $this->digit()->__toString()->shouldReturn('/\d/');
37
    }
38
39
    function it_should_assemble_right_pattern_with_literal()
40
    {
41
        $this->literal("a")->__toString()->shouldReturn('/a/');
42
    }
43
44
    function it_should_assemble_right_pattern_with_literals()
45
    {
46
        $this->literal("a", "b", "c")->__toString()->shouldReturn('/[abc]/');
47
    }
48
49
    function it_should_assemble_right_pattern_with_range()
50
    {
51
        $this->range("a", "z")->__toString()->shouldReturn('/[a-z]/');
52
    }
53
54
    function it_should_assemble_right_pattern_with_repetition()
55
    {
56
        $this->repetition("z", 2, 4)->__toString()->shouldReturn('/z{2,4}/');
57
    }
58
}
59