OperandStack::isEmpty()   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 0
crap 1
1
<?php
2
3
4
namespace CondParse;
5
6
7
class OperandStack
8
{
9
    /** @var \SplStack */
10
    private $stack;
11
12 15
    public function __construct(\SplStack $storage = null)
13
    {
14 15
        $this->stack = $storage ?: new \SplStack();
15 15
    }
16
17
    /**
18
     * @param OperandInterface $operand
19
     */
20 11
    public function push(OperandInterface $operand)
21
    {
22 11
        $this->stack->push($operand);
23 11
    }
24
25
    /**
26
     * @return OperandInterface
27
     */
28 9
    public function pop()
29
    {
30 9
        return $this->stack->pop();
31
    }
32
33
    /**
34
     * @return OperandInterface|null
35
     */
36 12
    public function top()
37
    {
38 12
        return $this->isEmpty()
39 12
            ? null
40 12
            : $this->stack->top();
41
    }
42
43
    /**
44
     * @return bool
45
     */
46 13
    public function isEmpty()
47
    {
48 13
        return $this->stack->isEmpty();
49
    }
50
}
51