Completed
Push — master ( 2d7c5c...16dc59 )
by Dev
09:53
created

Link   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 31
ccs 9
cts 13
cp 0.6923
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getUrl() 0 3 1
A getPageUrl() 0 3 1
A getElement() 0 3 1
A getAnchor() 0 3 1
1
<?php
2
3
namespace PiedWeb\UrlHarvester;
4
5
class Link
6
{
7
    private $url;
8
    private $anchor;
9
    private $element;
10
11 9
    public function __construct(string $url, $element)
12
    {
13 9
        $this->url = $url;
14 9
        $this->anchor = substr(Helper::clean($element->innertext), 0, 100);
15 9
        $this->element = $element;
16 9
    }
17
18 6
    public function getUrl()
19
    {
20 6
        return $this->url;
21
    }
22
23 3
    public function getPageUrl()
24
    {
25 3
        return preg_replace('/(\#.*)/si', '', $this->url);
26
    }
27
28
    public function getAnchor()
29
    {
30
        return $this->anchor;
31
    }
32
33
    public function getElement()
34
    {
35
        $this->element;
36
    }
37
}
38