Completed
Push — master ( 3f79e5...1ec99b )
by Kevin
02:42
created

Link::validate()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 25
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 25
ccs 0
cts 16
cp 0
rs 8.5806
cc 4
eloc 10
nc 4
nop 1
crap 20

1 Method

Rating   Name   Duplication   Size   Complexity  
A Link::doClean() 0 12 2
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\Element;
6
use Groundskeeper\Tokens\ElementTypes\ClosedElement;
7
use Groundskeeper\Tokens\ElementTypes\MetadataContent;
8
9
class Link extends ClosedElement implements MetadataContent
10
{
11
    protected function getAllowedAttributes()
12
    {
13
        $linkAllowedAttributes = array(
14
            '/^href$/i' => Element::ATTR_URI,
15
            '/^crossorigin$/i' => Element::ATTR_CS_STRING,
16
            '/^rel$/i' => Element::ATTR_CS_STRING,
17
            '/^media$/i' => Element::ATTR_CS_STRING,
18
            '/^hreflang$/i' => Element::ATTR_CS_STRING,
19
            '/^type$/i' => Element::ATTR_CS_STRING,
20
            '/^sizes$/i' => Element::ATTR_CS_STRING
21
        );
22
23
        return array_merge(
24
            $linkAllowedAttributes,
25
            parent::getAllowedAttributes()
26
        );
27
    }
28
29
    protected function doClean(LoggerInterface $logger = null)
30
    {
31
        // Must have "href" attribute.
32
        if (!$this->hasAttribute('href')) {
33
            return false;
34
        }
35
36
        // Must have either "rel" or "itemprop" attribute, but not both.
37
        /// @todo
38
39
        return true;
40
    }
41
}
42