Test Failed
Push — master ( 135f34...8b25c6 )
by Chris
33:49
created

MetaboxLayoutView   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 17
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 28 4
1
<?php
2
3
namespace Leonidas\Library\Admin\Component\Metabox\View;
4
5
use Leonidas\Contracts\Admin\Component\MetaboxComponentInterface;
6
use Leonidas\Contracts\Ui\ViewInterface;
7
use WebTheory\Html\Traits\ElementConstructorTrait;
8
9
class MetaboxLayoutView implements ViewInterface
10
{
11
    use ElementConstructorTrait;
12
13
    public function render(array $context = []): string
14
    {
15
        /** @var MetaboxComponentInterface[] $components */
16
        $components = $context['components'];
17
        $separator = $context['separator'];
18
        $request = $context['request'];
19
20
        $html = '';
21
        $html .= $context['auth_field'];
22
        $html .= $this->open('div', ['class' => 'leonidas-wrap']);
23
24
        $count = count($components);
25
26
        foreach ($components as $component) {
27
            $count--;
28
29
            if ($component->shouldBeRendered($request)) {
30
                $html .= $component->renderComponent($request);
31
32
                if ($count > 0) {
33
                    $html .= $separator;
34
                }
35
            }
36
        }
37
38
        $html .= $this->close('div');
39
40
        return $html;
41
    }
42
}
43