Passed
Push — master ( 463945...c0e83c )
by Bruno
08:14
created

Renderable_html::viewable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\Quill\Renderable;
4
5
use Formularium\Field;
6
use Formularium\HTMLElement;
7
use Formularium\Renderable;
8
9
class Renderable_html extends Renderable
10
{
11
    public function viewable($value, Field $field, HTMLElement $previous): HTMLElement
12
    {
13
        return $previous;
14
    }
15
   
16
    public function editable($value, Field $field, HTMLElement $previous): HTMLElement
17
    {
18
        $textarea = $previous->get('textarea')[0];
19
        $textarea->setTag('div');
20
        $id = $textarea->getAttribute('id')[0];
21
        $previous->appendContent(
22
            HTMLElement::factory(
23
                'script',
24
                [],
25
                "var quill = new Quill('#{$id}', { theme: 'snow' });",
26
                true
27
            )
28
        );
29
        return $previous;
30
    }
31
}
32