Renderable_relationship   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 8
c 2
b 1
f 0
dl 0
loc 26
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A viewable() 0 3 1
A editable() 0 9 2
1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Frontend\Bootstrap\Renderable;
4
5
use Formularium\Field;
6
use Formularium\Frontend\Bootstrap\RenderableBootstrapWrapperTrait;
7
use Formularium\Renderable;
8
use Formularium\HTMLNode;
9
10
class Renderable_relationship extends Renderable
11
{
12
    use RenderableBootstrapWrapperTrait;
13
    
14
    public function viewable($value, Field $field, HTMLNode $previous): HTMLNode
15
    {
16
        return $previous;
17
    }
18
19
    /**
20
     * Subcall of wrapper editable() from RenderableMaterializeTrait
21
     *
22
     * @param mixed $value
23
     * @param Field $field
24
     * @param HTMLNode $previous
25
     * @return HTMLNode
26
     */
27
    public function editable($value, Field $field, HTMLNode $previous): HTMLNode
28
    {
29
        foreach ($previous->get('select') as $input) {
30
            $input->addAttribute('class', 'custom-select');
31
        }
32
33
        $previous = $this->bootstrapify($value, $field, $previous, 'select');
34
        $previous = $this->bootstrapify($value, $field, $previous, 'input');
35
        return $this->wrapper($value, $field, $previous);
36
    }
37
}
38