Stack::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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