Total Complexity | 8 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 81.82% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
8 | class WithDirective extends Directive |
||
9 | { |
||
10 | |||
11 | protected static $index = 0; |
||
12 | protected static $storage = []; |
||
13 | |||
14 | 1 | protected static function calc() |
|
15 | { |
||
16 | 1 | static::$index = \count(static::$storage) - 1; |
|
17 | 1 | } |
|
18 | |||
19 | 1 | public static function &last() |
|
20 | { |
||
21 | 1 | return static::$storage[static::$index]; |
|
22 | } |
||
23 | |||
24 | public static function pushObject($data) |
||
28 | } |
||
29 | |||
30 | 1 | public static function push(&$data) |
|
31 | { |
||
32 | 1 | static::$storage[] = &$data; |
|
33 | 1 | static::calc(); |
|
34 | 1 | } |
|
35 | |||
36 | 1 | public static function pop() |
|
37 | { |
||
38 | 1 | if (!empty(static::$storage)) |
|
39 | { |
||
40 | 1 | Arr::pop(static::$storage); |
|
41 | 1 | static::$index--; |
|
42 | } |
||
43 | 1 | } |
|
44 | |||
45 | 1 | public function render(): string |
|
46 | { |
||
47 | 1 | return '<?php \\' . __CLASS__ . '::push(' . $this->data['name']['code'] . ')?>'; |
|
48 | } |
||
49 | |||
50 | 1 | public function endDirective(): string |
|
53 | } |
||
54 | |||
55 | } |
||
56 |