Title   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 5
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 58
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.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