Completed
Push — master ( 56b74c...17974d )
by Ilias
02:06
created

ToOperatorStack   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

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 14
    public function shouldExecuteFor(TokenParserParameter $parserParameter)
18
    {
19
        return
20 14
            $parserParameter->getLexerToken()->isToken(TokenMap::TOKEN_BRACKET_OPEN)
21 13
            || $parserParameter->getOperatorStack()->isEmpty()
22 13
            || $parserParameter->getTokenMap()->compareOperatorPrecedence(
23 9
                $parserParameter->getLexerToken(),
24 9
                $parserParameter->getOperatorStack()->top()
25 14
            ) > 0;
26
    }
27
28
    /**
29
     * @param TokenParserParameter $parserParameter
30
     * @return void
31
     */
32 12
    public function executeFor(TokenParserParameter $parserParameter)
33
    {
34 12
        $parserParameter->getOperatorStack()->push($parserParameter->getLexerToken());
35 12
    }
36
}
37