BlockDirective::endDirective()   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 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Bavix\Flow\Directives;
4
5
use Bavix\Flow\Directive;
6
use Bavix\FlowNative\Extensions\Blocks;
7
8
class BlockDirective extends Directive
9
{
10
11
    protected $extensions = [
12
        'reset'   => Blocks::RESET,
13
        'append'  => Blocks::APPEND,
14
        'prepend' => Blocks::PREPEND,
15
    ];
16
17
    /**
18
     * @return string
19
     */
20 1
    public function render(): string
21
    {
22 1
        $name = $this->data['name']['lexer']['fragment'];
23 1
        $type = $this->data['type']['lexer']['fragment'] ?? 'reset';
24
25 1
        return '<?php $this->ext->blocks()->start(\'' . $name . '\', \'' . $this->extensions[$type] . '\')?>';
26
    }
27
28
    /**
29
     * @return string
30
     */
31 1
    public function endDirective(): string
32
    {
33 1
        return '<?php echo $this->ext->blocks()->end()?>';
34
    }
35
36
}
37