Completed
Push — master ( 468061...6cd9bd )
by jelmer
02:14
created

Author::hasLink()   A

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 1
Bugs 0 Features 0
Metric Value
c 1
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 author will display a small section at the top of a message attachment.
10
 *
11
 * @author Jelmer Prins <[email protected]>
12
 *
13
 * @since 0.4.0
14
 */
15
final class Author extends SerializeToString
16
{
17
    /**
18
     * Small text used to display the author's name.
19
     *
20
     * @var string
21
     */
22
    private $name;
23
24
    /**
25
     * A valid URL that will hyperlink the name.
26
     *
27
     * @var Url|null
28
     */
29
    private $link;
30
31
    /**
32
     * A valid URL that displays a small 16x16px image to the left of the name.
33
     *
34
     * @var Url|null
35
     */
36
    private $icon;
37
38
    /**
39
     * Author constructor.
40
     *
41
     * @param string $name
42
     * @param Url|null $link
43
     * @param Url|null $icon
44
     */
45 3
    public function __construct($name, Url $link = null, Url $icon = null)
46
    {
47 3
        $this->name = $name;
48 3
        $this->link = $link;
49 3
        $this->icon = $icon;
50 3
    }
51
52
    /**
53
     * @return string
54
     */
55 1
    public function getName()
56
    {
57 1
        return $this->name;
58
    }
59
60
    /**
61
     * @return Url|null
62
     */
63 1
    public function getLink()
64
    {
65 1
        return $this->link;
66
    }
67
68
    /**
69
     * @return bool
70
     */
71 1
    public function hasLink()
72
    {
73 1
        return $this->link !== null;
74
    }
75
76
    /**
77
     * @return Url|null
78
     */
79 1
    public function getIcon()
80
    {
81 1
        return $this->icon;
82
    }
83
84
    /**
85
     * @return bool
86
     */
87 1
    public function hasIcon()
88
    {
89 1
        return $this->icon !== null;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95 1
    public function __toString()
96
    {
97 1
        return $this->getName();
98
    }
99
}
100