Stack   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 52
ccs 21
cts 21
cp 1
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getDepth() 0 3 1
A pop() 0 3 1
A __clone() 0 3 1
A current() 0 3 1
A isEmpty() 0 3 1
A push() 0 3 1
A frames() 0 3 1
A root() 0 3 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace JsonDecodeStream\Internal;
5
6
use SplStack;
7
8
class Stack
9
{
10
    protected $stack;
11
12 57
    public function __construct()
13
    {
14 57
        $this->stack = new SplStack();
15 57
    }
16
17 57
    public function push(StackFrame $frame)
18
    {
19 57
        $this->stack->push($frame);
20 57
    }
21
22 55
    public function pop()
23
    {
24 55
        $this->stack->pop();
25 55
    }
26
27
    /** @return StackFrame */
28 54
    public function current()
29
    {
30 54
        return $this->stack->top();
31
    }
32
33
    /** @return StackFrame */
34 1
    public function root()
35
    {
36 1
        return $this->stack->bottom();
37
    }
38
39 53
    public function isEmpty()
40
    {
41 53
        return $this->stack->isEmpty();
42
    }
43
44 5
    public function getDepth()
45
    {
46 5
        return $this->stack->count();
47
    }
48
49
    /**
50
     * @return StackFrame[]
51
     */
52 30
    public function frames()
53
    {
54 30
        return array_reverse(iterator_to_array($this->stack));
55
    }
56
57 1
    public function __clone()
58
    {
59 1
        $this->stack = clone $this->stack;
60 1
    }
61
}
62