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

Context::start()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 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