Passed
Branch master (4d781a)
by jelmer
02:23
created

Title   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 54
ccs 12
cts 12
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getTitle() 0 4 1
A hasLink() 0 4 1
A getLink() 0 4 1
A __toString() 0 4 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.3.2
15
 */
16
final class Title extends SerializeToString
17
{
18
    /**
19
     * @var string
20
     */
21
    private $title;
22
23
    /**
24
     * @var Url|null
25
     */
26
    private $link;
27
28
    /**
29
     * @param string $title
30
     * @param Url|null $link
31
     */
32 3
    public function __construct($title, Url $link = null)
33
    {
34 3
        $this->title = $title;
35 3
        $this->link = $link;
36 3
    }
37
38
    /**
39
     * @return string
40
     */
41 1
    public function getTitle()
42
    {
43 1
        return $this->title;
44
    }
45
46
    /**
47
     * @return bool
48
     */
49 1
    public function hasLink()
50
    {
51 1
        return $this->link !== null;
52
    }
53
54
    /**
55
     * @return Url|null
56
     */
57 1
    public function getLink()
58
    {
59 1
        return $this->link;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65 1
    public function __toString()
66
    {
67 1
        return $this->getTitle();
68
    }
69
}
70