Passed
Push — master ( 192b45...fd1497 )
by Bruno
06:54
created

Renderable::factory()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5.3256

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 5
eloc 18
c 3
b 0
f 0
nc 16
nop 2
dl 0
loc 25
ccs 13
cts 17
cp 0.7647
crap 5.3256
rs 9.3554
1
<?php declare(strict_types=1);
2
3
namespace Formularium;
4
5
use Formularium\Exception\ClassNotFoundException;
6
use Formularium\Exception\Exception;
7
use Formularium\HTMLNode;
8
9
/**
10
 * Abstract base classe to render datatypes. This class should be extended by frontends
11
 * for each datatype.
12
 */
13
abstract class Renderable implements RenderableParameter
14
{
15
    /**
16
     * @var Framework
17
     */
18
    protected $framework;
19
20
    public function __construct(Framework $framework)
21
    {
22 4
        $this->framework = $framework;
23
    }
24 4
    /**
25 2
     * Renders a view-only version of this renderable.
26
     *
27 2
     * @param mixed $value The value to render.
28 2
     * @param Field $field The field.
29
     * @param HTMLNode $previous The HTML coming from the previous composer.
30
     * @return HTMLNode The HTML rendered.
31 3
     */
32 3
    abstract public function viewable($value, Field $field, HTMLNode $previous): HTMLNode;
33 3
34
    /**
35
     * Renders a form editable version of this renderable
36 3
     *
37
     * @param mixed $value The value to render.
38 3
     * @param Field $field The field.
39 3
     * @param HTMLNode $previous The HTML coming from the previous composer.
40
     * @return HTMLNode The HTML rendered.
41
     */
42
    abstract public function editable($value, Field $field, HTMLNode $previous): HTMLNode;
43
}
44