Author   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 7
c 3
b 1
f 1
lcom 2
cbo 1
dl 0
loc 85
ccs 17
cts 17
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getIcon() 0 4 1
A hasIcon() 0 4 1
A __toString() 0 4 1
A __construct() 0 6 1
A getLink() 0 4 1
A hasLink() 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 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 4
    public function __construct($name, Url $link = null, Url $icon = null)
46
    {
47 4
        $this->name = $name;
48 4
        $this->link = $link;
49 4
        $this->icon = $icon;
50 4
    }
51
52
    /**
53
     * @return string
54
     */
55 2
    public function getName()
56
    {
57 2
        return $this->name;
58
    }
59
60
    /**
61
     * @return Url|null
62
     */
63 2
    public function getLink()
64
    {
65 2
        return $this->link;
66
    }
67
68
    /**
69
     * @return bool
70
     */
71 2
    public function hasLink()
72
    {
73 2
        return $this->link !== null;
74
    }
75
76
    /**
77
     * @return Url|null
78
     */
79 2
    public function getIcon()
80
    {
81 2
        return $this->icon;
82
    }
83
84
    /**
85
     * @return bool
86
     */
87 2
    public function hasIcon()
88
    {
89 2
        return $this->icon !== null;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95 2
    public function __toString()
96
    {
97 2
        return $this->getName();
98
    }
99
}
100