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

Link   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 3
c 4
b 1
f 1
lcom 0
cbo 1
dl 0
loc 33
ccs 0
cts 23
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedAttributes() 0 17 1
A 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