Link   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 27
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 7 2
A __construct() 0 9 3
A setTitle() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
11
 *  - (c) John MacFarlane
12
 *
13
 * For the full copyright and license information, please view the LICENSE
14
 * file that was distributed with this source code.
15
 */
16
17
namespace League\CommonMark\Extension\CommonMark\Node\Inline;
18
19
use League\CommonMark\Node\Inline\Text;
20
21
class Link extends AbstractWebResource
22
{
23
    protected ?string $title = null;
24
25 660
    public function __construct(string $url, ?string $label = null, ?string $title = null)
26
    {
27 660
        parent::__construct($url);
28
29 660
        if ($label !== null && $label !== '') {
30 402
            $this->appendChild(new Text($label));
31
        }
32
33 660
        $this->title = $title;
34
    }
35
36 620
    public function getTitle(): ?string
37
    {
38 620
        if ($this->title === '') {
39 210
            return null;
40
        }
41
42 424
        return $this->title;
43
    }
44
45
    public function setTitle(?string $title): void
46
    {
47
        $this->title = $title;
48
    }
49
}
50