Completed
Push — master ( 684ebe...b755f3 )
by Freek
10s
created

ContextStack   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A push() 0 4 1
A read() 0 4 1
A pop() 0 4 1
1
<?php
2
3
namespace Spatie\BladeX;
4
5
class ContextStack
6
{
7
    /** @var array */
8
    protected $stack = [];
9
10
    public function push(array $data)
11
    {
12
        $this->stack[] = array_merge($this->read(), $data);
13
    }
14
15
    public function read(): array
16
    {
17
        return array_last($this->stack) ?? [];
18
    }
19
20
    public function pop()
21
    {
22
        array_pop($this->stack);
23
    }
24
25
}
26