Passed
Push — main ( 989696...2152d5 )
by Colin
05:14 queued 02:09
created

Link   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 6
eloc 10
dl 0
loc 28
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

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
    /** @var string|null */
24
    protected $title;
25
26 903
    public function __construct(string $url, ?string $label = null, ?string $title = null)
27
    {
28 903
        parent::__construct($url);
29
30 903
        if ($label !== null && $label !== '') {
31 552
            $this->appendChild(new Text($label));
32
        }
33
34 903
        $this->title = $title;
35 903
    }
36
37 861
    public function getTitle(): ?string
38
    {
39 861
        if ($this->title === '') {
40 279
            return null;
41
        }
42
43 603
        return $this->title;
44
    }
45
46
    public function setTitle(?string $title): void
47
    {
48
        $this->title = $title;
49
    }
50
}
51