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

Link::doClean()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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