Test Failed
Push — master ( f2bdc0...e2cac0 )
by Chris
29:08
created

Html::constructHtml()   B

Complexity

Conditions 10
Paths 20

Size

Total Lines 44
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 10
eloc 22
c 1
b 0
f 0
nc 20
nop 2
dl 0
loc 44
rs 7.6666

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace WebTheory\Html;
4
5
use WebTheory\Html\Traits\ElementConstructorTrait;
6
7
/**
8
 * @method static string div(string $inner = '', array attributes = [])
9
 * @method static string span(string $inner = '', array attributes = [])
10
 * @method static string main(string $inner = '', array attributes = [])
11
 * @method static string form(string $inner = '', array attributes = [])
12
 * @method static string h1(string $inner = '', array attributes = [])
13
 * @method static string h2(string $inner = '', array attributes = [])
14
 * @method static string h3(string $inner = '', array attributes = [])
15
 * @method static string h4(string $inner = '', array attributes = [])
16
 * @method static string h5(string $inner = '', array attributes = [])
17
 * @method static string h6(string $inner = '', array attributes = [])
18
 * @method static string input(array attributes = [])
19
 */
20
class Html
21
{
22
    use ElementConstructorTrait {
23
        tag as public;
24
        open as public;
25
        close as public;
26
        maybeClose as public;
27
        tagIsVoid as public;
28
    }
29
30
    /**
31
     *
32
     */
33
    public static function attributes(array $attributes, bool $trim = true)
34
    {
35
        $attributes = static::parseAttributes($attributes);
36
37
        return $trim ? ltrim($attributes) : $attributes;
38
    }
39
40
    /**
41
     *
42
     */
43
    public static function __callStatic($tag, $args)
44
    {
45
        if (static::tagIsVoid($tag)) {
46
            return static::tag($tag, $args[0] ?? []);
47
        }
48
49
        return static::tag($tag, $args[1] ?? [], $args[0] ?? '');
50
    }
51
}
52