ClosingBracket::shouldExecuteFor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
4
namespace CondParse\ParseStrategy;
5
6
7
use CondParse\TokenMap;
8
use CondParse\TokenParserParameter;
9
10
class ClosingBracket implements ParseStrategyInterface
11
{
12
13
    /**
14
     * @param TokenParserParameter $parserParameter
15
     * @return bool
16
     */
17 8
    public function shouldExecuteFor(TokenParserParameter $parserParameter)
18
    {
19 8
        return $parserParameter->getLexerToken()->isToken(TokenMap::TOKEN_BRACKET_CLOSE);
20
    }
21
22
    /**
23
     * @param TokenParserParameter $parserParameter
24
     * @return void
25
     */
26 5
    public function executeFor(TokenParserParameter $parserParameter)
27
    {
28 5
        while (! $parserParameter->getOperatorStack()->top()->isToken(TokenMap::TOKEN_BRACKET_OPEN)) {
29 4
            $parserParameter->getOperandStack()->push(
30
                $parserParameter
31 4
                    ->getTokenMap()
32 4
                    ->buildOperand($parserParameter->getOperatorStack()->pop())
33 4
                    ->consumeTokens($parserParameter->getOperandStack())
34 4
            );
35 4
        }
36
37 5
        $parserParameter->getOperatorStack()->pop();
38 5
    }
39
}
40