Completed
Push — develop ( 782b4e...557e80 )
by Adrien
43:38
created

CyclicReferenceStack::showStack()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Calculation\Engine;
4
5
class CyclicReferenceStack
6
{
7
    /**
8
     * The call stack for calculated cells.
9
     *
10
     * @var mixed[]
11
     */
12
    private $stack = [];
13
14
    /**
15
     * Return the number of entries on the stack.
16
     *
17
     * @return int
18
     */
19
    public function count()
20
    {
21
        return count($this->stack);
22
    }
23
24
    /**
25
     * Push a new entry onto the stack.
26
     *
27
     * @param mixed $value
28
     */
29 117
    public function push($value)
30
    {
31 117
        $this->stack[$value] = $value;
32 117
    }
33
34
    /**
35
     * Pop the last entry from the stack.
36
     *
37
     * @return mixed
38
     */
39 117
    public function pop()
40
    {
41 117
        return array_pop($this->stack);
42
    }
43
44
    /**
45
     * Test to see if a specified entry exists on the stack.
46
     *
47
     * @param mixed $value The value to test
48
     */
49 60
    public function onStack($value)
50
    {
51 60
        return isset($this->stack[$value]);
52
    }
53
54
    /**
55
     * Clear the stack.
56
     */
57 47
    public function clear()
58
    {
59 47
        $this->stack = [];
60 47
    }
61
62
    /**
63
     * Return an array of all entries on the stack.
64
     *
65
     * @return mixed[]
66
     */
67
    public function showStack()
68
    {
69
        return $this->stack;
70
    }
71
}
72