Passed
Push — master ( 0b0ed1...849c84 )
by Bruno
02:30
created

Framework   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 73
rs 10
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getRenderable() 0 3 1
A __construct() 0 3 1
A factory() 0 7 2
A getName() 0 3 1
A htmlHead() 0 3 1
A htmlFooter() 0 3 1
A editableCompose() 0 3 1
A viewableCompose() 0 3 1
1
<?php
2
3
namespace Formularium;
4
5
use Formularium\Exception\Exception;
6
use Formularium\HTMLElement;
7
8
abstract class Framework
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $name;
14
15
    public function __construct(string $name)
16
    {
17
        $this->name = $name;
18
    }
19
20
    public static function factory(string $framework = ''): Framework
21
    {
22
        $class = "\\Formularium\\Frontend\\$framework\\Framework";
23
        if (!class_exists($class)) {
24
            throw new Exception("Invalid framework $framework");
25
        }
26
        return new $class();
27
    }
28
29
    public function getRenderable(Datatype $datatype): Renderable
30
    {
31
        return Renderable::factory($datatype, $this);
32
    }
33
34
    public function getName(): string
35
    {
36
        return $this->name;
37
    }
38
39
    /**
40
     * Returns a string with the <head> HTML to generate standalone files.
41
     * This is used by the kitchensink generator.
42
     *
43
     * @return string
44
     */
45
    public function htmlHead(): string
46
    {
47
        return '';
48
    }
49
50
    /**
51
     * Returns a string with things to add to the footer of the page (such as scripts)
52
     * This is used by the kitchensink generator.
53
     *
54
     * @return string
55
     */
56
    public function htmlFooter(): string
57
    {
58
        return '';
59
    }
60
61
    /**
62
     * @param Model $m
63
     * @param HTMLElement[] $elements
64
     * @param string $previousCompose
65
     * @return string
66
     */
67
    public function editableCompose(Model $m, array $elements, string $previousCompose): string
0 ignored issues
show
Unused Code introduced by
The parameter $m is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

67
    public function editableCompose(/** @scrutinizer ignore-unused */ Model $m, array $elements, string $previousCompose): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $elements is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

67
    public function editableCompose(Model $m, /** @scrutinizer ignore-unused */ array $elements, string $previousCompose): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
68
    {
69
        return $previousCompose;
70
    }
71
72
    /**
73
     * @param Model $m
74
     * @param HTMLElement[] $elements
75
     * @param string $previousCompose
76
     * @return string
77
     */
78
    public function viewableCompose(Model $m, array $elements, string $previousCompose): string
0 ignored issues
show
Unused Code introduced by
The parameter $elements is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

78
    public function viewableCompose(Model $m, /** @scrutinizer ignore-unused */ array $elements, string $previousCompose): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $m is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

78
    public function viewableCompose(/** @scrutinizer ignore-unused */ Model $m, array $elements, string $previousCompose): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
79
    {
80
        return $previousCompose;
81
    }
82
}
83