FlashesTokenParserSpec   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 2
dl 0
loc 145
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 11 1
A it_should_be_a_twig_token_parser() 0 4 1
A it_should_handle_flashes_tags() 0 4 1
A it_should_parse_complete_flashes_tag() 0 18 1
A it_should_parse_flashes_tag_with_no_specified_catalog() 0 17 1
A it_should_parse_flashes_tag_with_no_specified_types() 0 17 1
A it_should_parse_flashes_tag_with_no_specified_types_nor_catalog() 0 15 1
A its_isEndTag_should_return_true_recognize_end_tag_token() 0 6 1
A its_isEndTag_should_return_false_otherwise() 0 6 1
1
<?php
2
3
namespace spec\Knp\RadBundle\Twig;
4
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
8
class FlashesTokenParserSpec extends ObjectBehavior
9
{
10
    /**
11
     * @param  Twig_Parser                           $parser
12
     * @param  Twig_ExpressionParser                 $exprParser
13
     * @param  Twig_TokenStream                      $stream
14
     * @param  Twig_Token                            $token
15
     * @param  Twig_NodeInterface                    $body
0 ignored issues
show
Bug introduced by
There is no parameter named $body. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
16
     * @param  Knp\RadBundle\Twig\FlashesNodeFactory $nodeFactory
17
     * @param  Knp\RadBundle\Twig\FlashesNode        $node
0 ignored issues
show
Bug introduced by
There is no parameter named $node. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
18
     */
19
    function let($parser, $exprParser, $stream, $nodeFactory, $token)
20
    {
21
        $this->beConstructedWith($nodeFactory);
22
23
        $parser->getStream()->willReturn($stream);
24
        $parser->getExpressionParser()->willReturn($exprParser);
25
26
        $token->getLine()->willReturn(123);
27
28
        $this->setParser($parser);
29
    }
30
31
    function it_should_be_a_twig_token_parser()
0 ignored issues
show
Coding Style introduced by
Method name "FlashesTokenParserSpec::it_should_be_a_twig_token_parser" is not in camel caps format
Loading history...
32
    {
33
        $this->shouldBeAnInstanceOf('Twig_TokenParserInterface');
34
    }
35
36
    function it_should_handle_flashes_tags()
0 ignored issues
show
Coding Style introduced by
Method name "FlashesTokenParserSpec::it_should_handle_flashes_tags" is not in camel caps format
Loading history...
37
    {
38
        $this->getTag()->shouldReturn('flashes');
39
    }
40
41
    /**
42
     * {% flashes {expr:types} using catalog {expr:catalog} %}
43
     *      <div class="flash {{ type }}">{{ message }}</div>
44
     * {% endflashes %}
45
     *
46
     * @param  Twig_Node_Expression $types
47
     * @param  Twig_Node_Expression $catalog
48
     */
49
    function it_should_parse_complete_flashes_tag(
0 ignored issues
show
Coding Style introduced by
Method name "FlashesTokenParserSpec::it_should_parse_complete_flashes_tag" is not in camel caps format
Loading history...
50
        $parser, $exprParser, $stream, $body, $nodeFactory, $node, $token, $types, $catalog
0 ignored issues
show
Coding Style introduced by
Multi-line function declarations must define one parameter per line
Loading history...
51
    )
52
    {
0 ignored issues
show
Coding Style introduced by
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
53
        $stream->test(\Twig_Token::BLOCK_END_TYPE)->willReturn(false);
54
        $stream->test(\Twig_Token::NAME_TYPE, 'using')->willReturn(false, true);
55
56
        $stream->expect(Argument::any())->will(function() {});
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
57
        $stream->expect(Argument::cetera())->will(function() {});
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
58
59
        $exprParser->parseExpression()->willReturn($types, $catalog);
60
61
        $parser->subparse(array($this, 'isEndTag'), true)->willReturn($body);
62
63
        $nodeFactory->createFlashesNode($types, $catalog, $body, 123)->willReturn($node);
64
65
        $this->parse($token)->shouldReturn($node);
66
    }
67
68
    /**
69
     * {% flashes {expr:types} %}
70
     *      <div class="flash {{ type }}">{{ message }}</div>
71
     * {% endflashes %}
72
     *
73
     * @param  Twig_Node_Expression $types
74
     */
75
    function it_should_parse_flashes_tag_with_no_specified_catalog(
0 ignored issues
show
Coding Style introduced by
Method name "FlashesTokenParserSpec::it_should_parse_flashes_tag_with_no_specified_catalog" is not in camel caps format
Loading history...
76
        $parser, $exprParser, $stream, $body, $nodeFactory, $node, $token, $types
0 ignored issues
show
Coding Style introduced by
Multi-line function declarations must define one parameter per line
Loading history...
77
    )
78
    {
0 ignored issues
show
Coding Style introduced by
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
79
        $stream->test(\Twig_Token::NAME_TYPE, 'using')->willReturn(false, false);
80
        $stream->test(\Twig_Token::BLOCK_END_TYPE)->willReturn(false);
81
82
        $exprParser->parseExpression()->willReturn($types);
83
84
        $stream->expect(\Twig_Token::BLOCK_END_TYPE)->will(function() {});
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
85
86
        $parser->subparse(array($this, 'isEndTag'), true)->willReturn($body);
87
88
        $nodeFactory->createFlashesNode($types, null, $body, 123)->willReturn($node);
89
90
        $this->parse($token)->shouldReturn($node);
91
    }
92
93
    /**
94
     * {% flashes using catalog {expr:catalog} %}
95
     *      <div class="flash {{ type }}">{{ message }}</div>
96
     * {% endflashes %}
97
     *
98
     * @param  Twig_Node_Expression $catalog
99
     */
100
    function it_should_parse_flashes_tag_with_no_specified_types(
0 ignored issues
show
Coding Style introduced by
Method name "FlashesTokenParserSpec::it_should_parse_flashes_tag_with_no_specified_types" is not in camel caps format
Loading history...
101
        $parser, $exprParser, $stream, $body, $nodeFactory, $node, $token, $catalog
0 ignored issues
show
Coding Style introduced by
Multi-line function declarations must define one parameter per line
Loading history...
102
    )
103
    {
0 ignored issues
show
Coding Style introduced by
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
104
        $stream->test(\Twig_Token::NAME_TYPE, 'using')->willReturn(true, true);
105
        $stream->expect(\Twig_Token::NAME_TYPE, 'using')->will(function() {});
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
106
        $stream->expect(\Twig_Token::NAME_TYPE, 'catalog')->will(function() {});
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
107
        $stream->expect(\Twig_Token::BLOCK_END_TYPE)->will(function() {});
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
108
109
        $exprParser->parseExpression()->willReturn($catalog);
110
111
        $parser->subparse(array($this, 'isEndTag'), true)->willReturn($body);
112
113
        $nodeFactory->createFlashesNode(null, $catalog, $body, 123)->willReturn($node);
114
115
        $this->parse($token)->shouldReturn($node);
116
    }
117
118
    /**
119
     * {% flashes using catalog {expr:catalog} %}
120
     *      <div class="flash {{ type }}">{{ message }}</div>
121
     * {% endflashes %}
122
     */
123
    function it_should_parse_flashes_tag_with_no_specified_types_nor_catalog(
0 ignored issues
show
Coding Style introduced by
Method name "FlashesTokenParserSpec::it_should_parse_flashes_tag_with_no_specified_types_nor_catalog" is not in camel caps format
Loading history...
124
        $parser, $exprParser, $stream, $body, $nodeFactory, $node, $token
0 ignored issues
show
Unused Code introduced by
The parameter $exprParser is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Multi-line function declarations must define one parameter per line
Loading history...
125
    )
126
    {
0 ignored issues
show
Coding Style introduced by
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
127
        $stream->test(\Twig_Token::NAME_TYPE, 'using')->willReturn(false, false);
128
        $stream->test(\Twig_Token::BLOCK_END_TYPE)->willReturn(true);
129
130
        $stream->expect(\Twig_Token::BLOCK_END_TYPE)->will(function() {});
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
131
132
        $parser->subparse(array($this, 'isEndTag'), true)->willReturn($body);
133
134
        $nodeFactory->createFlashesNode(null, null, $body, 123)->willReturn($node);
135
136
        $this->parse($token)->shouldReturn($node);
137
    }
138
139
    function its_isEndTag_should_return_true_recognize_end_tag_token($token)
0 ignored issues
show
Coding Style introduced by
Method name "FlashesTokenParserSpec::its_isEndTag_should_return_true_recognize_end_tag_token" is not in camel caps format
Loading history...
140
    {
141
        $token->test('endflashes')->willReturn(true);
142
143
        $this->isEndTag($token)->shouldReturn(true);
144
    }
145
146
    function its_isEndTag_should_return_false_otherwise($token)
0 ignored issues
show
Coding Style introduced by
Method name "FlashesTokenParserSpec::its_isEndTag_should_return_false_otherwise" is not in camel caps format
Loading history...
147
    {
148
        $token->test('endflashes')->willReturn(false);
149
150
        $this->isEndTag($token)->shouldReturn(false);
151
    }
152
}
153