ToOperatorStack   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldExecuteFor() 0 10 3
A executeFor() 0 4 1
1
<?php
2
3
4
namespace CondParse\ParseStrategy;
5
6
7
use CondParse\TokenMap;
8
use CondParse\TokenParserParameter;
9
10
class ToOperatorStack implements ParseStrategyInterface
11
{
12
13
    /**
14
     * @param TokenParserParameter $parserParameter
15
     * @return bool
16
     */
17 16
    public function shouldExecuteFor(TokenParserParameter $parserParameter)
18
    {
19
        return
20 16
            $parserParameter->getLexerToken()->isToken(TokenMap::TOKEN_BRACKET_OPEN)
21 13
            || $parserParameter->getOperatorStack()->isEmpty()
22 13
            || $parserParameter->getTokenMap()->compareOperatorPrecedence(
23 8
                $parserParameter->getLexerToken(),
24 8
                $parserParameter->getOperatorStack()->top()
25 16
            ) > 0;
26
    }
27
28
    /**
29
     * @param TokenParserParameter $parserParameter
30
     * @return void
31
     */
32 10
    public function executeFor(TokenParserParameter $parserParameter)
33
    {
34 10
        $parserParameter->getOperatorStack()->push($parserParameter->getLexerToken());
35 10
    }
36
}
37