Completed
Push — master ( 222ce6...a37246 )
by Pol
16s
created

HtmlTag::comment()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 17
loc 17
ccs 8
cts 8
cp 1
rs 9.7
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace drupol\htmltag;
4
5
use drupol\htmltag\Attribute\AttributeFactory;
6
use drupol\htmltag\Attributes\AttributesFactory;
7
use drupol\htmltag\Tag\CommentFactory;
8
use drupol\htmltag\Tag\TagFactory;
9
10
/**
11
 * Class HtmlTag
12
 */
13
class HtmlTag implements HtmlTagInterface
14
{
15
    /**
16
     * The attribute factory classname.
17
     *
18
     * @var string
19
     */
20
    protected $attribute_factory_classname = AttributeFactory::class;
21
22
    /**
23
     * The attributes factory classname.
24
     *
25
     * @var string
26
     */
27
    protected $attributes_factory_classname = AttributesFactory::class;
28
29
    /**
30
     * The tag factory classname.
31
     *
32
     * @var string
33
     */
34
    protected $tag_factory_classname = TagFactory::class;
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 2
    public static function tag(
40
        $name,
41
        array $attributes = [],
42
        $content = null,
43
        $attribute_factory_classname = null,
44
        $attributes_factory_classname = null,
45
        $tag_factory_classname = null
46
    ) {
47 2
        $static = new static();
48
49 2
        $attributes_factory_classname = null == $attributes_factory_classname ?
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $attributes_factory_classname of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
50 2
            $static->attributes_factory_classname :
51 2
            $attributes_factory_classname;
52
53 2
        $attribute_factory_classname = null == $attribute_factory_classname ?
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $attribute_factory_classname of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
54 2
            $static->attribute_factory_classname :
55 2
            $attribute_factory_classname;
56
57 2
        $tag_factory_classname = null == $tag_factory_classname ?
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $tag_factory_classname of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
58 2
            $static->tag_factory_classname :
59 2
            $tag_factory_classname;
60
        /** @var \drupol\htmltag\Tag\TagFactoryInterface $tag_factory_classname */
61 2
        $tag_factory_classname = (new \ReflectionClass($tag_factory_classname))->newInstance();
62
63 2
        return $tag_factory_classname::build(
64 2
            $name,
65 2
            $attributes,
66 2
            $content,
67 2
            $attribute_factory_classname,
68 2
            $attributes_factory_classname
69
        );
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75 1
    public static function attributes(
76
        array $attributes = [],
77
        $attribute_factory_classname = null,
78
        $attributes_factory_classname = null
79
    ) {
80 1
        $static = new static();
81
82 1
        $attribute_factory_classname = null == $attribute_factory_classname ?
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $attribute_factory_classname of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
83 1
            $static->attribute_factory_classname :
84 1
            $attribute_factory_classname;
85
86 1
        $attributes_factory_classname = null == $attributes_factory_classname ?
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $attributes_factory_classname of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
87 1
            $static->attributes_factory_classname :
88 1
            $attributes_factory_classname;
89
90
        /** @var \drupol\htmltag\Attributes\AttributesFactoryInterface $attributes_factory_classname */
91 1
        $attributes_factory_classname = (new \ReflectionClass($attributes_factory_classname))->newInstance();
92
93 1
        return $attributes_factory_classname::build(
94 1
            $attributes,
95 1
            $attribute_factory_classname
96
        );
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102 1
    public static function attribute(
103
        $name,
104
        $value,
105
        $attribute_factory_classname = null
106
    ) {
107 1
        $static = new static();
108
109 1
        $attribute_factory_classname = null == $attribute_factory_classname ?
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $attribute_factory_classname of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
110 1
            $static->attribute_factory_classname :
111 1
            $attribute_factory_classname;
112
113
        /** @var \drupol\htmltag\Attribute\AttributeFactoryInterface $attribute_factory_classname */
114 1
        $attribute_factory_classname = (new \ReflectionClass($attribute_factory_classname))->newInstance();
115
116 1
        return $attribute_factory_classname::build($name, $value);
117
    }
118
}
119