ImageTrait   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 95
ccs 15
cts 15
cp 1
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setTitle() 0 5 1
A getAltText() 0 3 1
A getUrl() 0 3 1
A setAltText() 0 5 1
A setUrl() 0 5 1
A getTitle() 0 3 1
1
<?php
2
namespace Maknz\Slack;
3
4
use Maknz\Slack\BlockElement\Text;
5
6
trait ImageTrait
7
{
8
    /**
9
     * The image URL.
10
     *
11
     * @var string
12
     */
13
    protected $url;
14
15
    /**
16
     * The alternative text for the image.
17
     *
18
     * @var string
19
     */
20
    protected $alt_text;
21
22
    /**
23
     * The image title.
24
     *
25
     * @var \Maknz\Slack\BlockElement\Text
26
     */
27
    protected $title;
28
29
    /**
30
     * Get the image URL.
31
     *
32
     * @return string
33
     */
34 5
    public function getUrl()
35
    {
36 5
        return $this->url;
37
    }
38
39
    /**
40
     * Set the image URL.
41
     *
42
     * @param string $url
43
     *
44
     * @return $this
45
     */
46 6
    public function setUrl($url)
47
    {
48 6
        $this->url = $url;
49
50 6
        return $this;
51
    }
52
53
    /**
54
     * Get the alternative text for the image.
55
     *
56
     * @return string
57
     */
58 5
    public function getAltText()
59
    {
60 5
        return $this->alt_text;
61
    }
62
63
    /**
64
     * Set the alternative text for the image.
65
     *
66
     * @param mixed $text
67
     *
68
     * @return $this
69
     */
70 6
    public function setAltText($text)
71
    {
72 6
        $this->alt_text = $text;
73
74 6
        return $this;
75
    }
76
77
    /**
78
     * Get the image title.
79
     *
80
     * @return \Maknz\Slack\BlockElement\Text
81
     */
82 5
    public function getTitle()
83
    {
84 5
        return $this->title;
85
    }
86
87
    /**
88
     * Set the image title.
89
     *
90
     * @param mixed $title
91
     *
92
     * @return $this
93
     *
94
     * @throws \InvalidArgumentException
95
     */
96 4
    public function setTitle($title)
97
    {
98 4
        $this->title = Text::create($title, Text::TYPE_PLAIN);
99
100 4
        return $this;
101
    }
102
}
103