Title::getLink()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Pageon\SlackWebhookMonolog\Slack\Attachment;
4
5
use Pageon\SlackWebhookMonolog\General\SerializeToString;
6
use Pageon\SlackWebhookMonolog\General\Url;
7
8
/**
9
 * The title is displayed as larger, bold text near the top of a message attachment.
10
 * By passing a valid URL in the link parameter (optional), the title text will be hyperlinked.
11
 *
12
 * @author Jelmer Prins <[email protected]>
13
 *
14
 * @since 0.4.0
15
 */
16
final class Title extends SerializeToString
17
{
18
    /**
19
     * The title is displayed as larger, bold text near the top of a message attachment.
20
     *
21
     * @var string
22
     */
23
    private $title;
24
25
    /**
26
     * By passing a valid URL in the link parameter (optional), the title text will be hyperlinked.
27
     *
28
     * @var Url|null
29
     */
30
    private $link;
31
32
    /**
33
     * @param string $title
34
     * @param Url|null $link
35
     */
36 10
    public function __construct($title, Url $link = null)
37
    {
38 10
        $this->title = $title;
39 10
        $this->link = $link;
40 10
    }
41
42
    /**
43
     * @return string
44
     */
45 8
    public function getTitle()
46
    {
47 8
        return $this->title;
48
    }
49
50
    /**
51
     * @return bool
52
     */
53 8
    public function hasLink()
54
    {
55 8
        return $this->link !== null;
56
    }
57
58
    /**
59
     * @return Url|null
60
     */
61 2
    public function getLink()
62
    {
63 2
        return $this->link;
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 8
    public function __toString()
70
    {
71 8
        return $this->getTitle();
72
    }
73
}
74