Completed
Pull Request — master (#20)
by Sebastian
01:55
created

Context   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 11 1
A end() 0 4 1
A read() 0 4 1
1
<?php
2
3
namespace Spatie\BladeX;
4
5
class Context
6
{
7
    /** @var array */
8
    protected $data = [];
9
10
    public function start(array $definedVars)
11
    {
12
        $data = array_except(
13
            $definedVars,
14
            ['__path', '__data', 'obLevel', '__env', 'app', 'slot']
15
        );
16
17
        $previousData = array_last($this->data) ?? [];
18
19
        $this->data[] = array_merge($previousData, $data);
20
    }
21
22
    public function end()
23
    {
24
        array_pop($this->data);
25
    }
26
27
    public function read()
28
    {
29
        return array_last($this->data) ?? [];
30
    }
31
}
32