Html   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 38
c 0
b 0
f 0
rs 10
ccs 6
cts 6
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasSurroundingAttributes() 0 4 2
A isDataAttribute() 0 4 1
A isLastAttribute() 0 4 1
1
<?php
2
3
namespace ArjanSchouten\HtmlMinifier\Util;
4
5
use Illuminate\Support\Str;
6
7
class Html
8
{
9
    /**
10
     * Check if an attribute has surrounding attributes.
11
     *
12
     * @param string $attribute
13
     *
14
     * @return bool
15
     */
16 5
    public static function hasSurroundingAttributes($attribute)
17
    {
18 5
        return Str::startsWith($attribute, ' ') && Str::endsWith($attribute, ' ');
19
    }
20
21
    /**
22
     * Check if an attribute is a HTML 5 data-* attribute.
23
     *
24
     * @param string $attribute
25
     *
26
     * @return int
27
     */
28 5
    public static function isDataAttribute($attribute)
29
    {
30 5
        return preg_match('/data-/', $attribute);
31
    }
32
33
    /**
34
     * Check if an attribute is the last attribute of the element.
35
     *
36
     * @param  $attribute
37
     *
38
     * @return bool
39
     */
40 2
    public static function isLastAttribute($attribute)
41
    {
42 2
        return !Str::endsWith($attribute, ' ');
43
    }
44
}
45