Html::isDataAttribute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 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