AttachmentField::getTitle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
namespace Maknz\Slack;
3
4
class AttachmentField extends Payload implements Field
5
{
6
    /**
7
     * The required title field of the field.
8
     *
9
     * @var string
10
     */
11
    protected $title;
12
13
    /**
14
     * The required value of the field.
15
     *
16
     * @var string
17
     */
18
    protected $value;
19
20
    /**
21
     * Whether the value is short enough to fit side by side with
22
     * other values.
23
     *
24
     * @var bool
25
     */
26
    protected $short = false;
27
28
    /**
29
     * Internal attribute to property map.
30
     *
31
     * @var array
32
     */
33
    protected static $availableAttributes = [
34
        'title' => 'title',
35
        'value' => 'value',
36
        'short' => 'short',
37
    ];
38
39
    /**
40
     * Instantiate a new AttachmentField.
41
     *
42
     * @param array $attributes
43
     */
44 7
    public function __construct(array $attributes)
45
    {
46 7
        parent::__construct($attributes);
47 7
    }
48
49
    /**
50
     * Get the title of the field.
51
     *
52
     * @return string
53
     */
54 5
    public function getTitle()
55
    {
56 5
        return $this->title;
57
    }
58
59
    /**
60
     * Set the title of the field.
61
     *
62
     * @param string $title
63
     * @return $this
64
     */
65 7
    public function setTitle($title)
66
    {
67 7
        $this->title = $title;
68
69 7
        return $this;
70
    }
71
72
    /**
73
     * Get the value of the field.
74
     *
75
     * @return string
76
     */
77 3
    public function getValue()
78
    {
79 3
        return $this->value;
80
    }
81
82
    /**
83
     * Set the value of the field.
84
     *
85
     * @param string $value
86
     * @return $this
87
     */
88 7
    public function setValue($value)
89
    {
90 7
        $this->value = $value;
91
92 7
        return $this;
93
    }
94
95
    /**
96
     * Get whether this field is short enough for displaying
97
     * side-by-side with other fields.
98
     *
99
     * @return bool
100
     */
101 3
    public function getShort()
102
    {
103 3
        return $this->short;
104
    }
105
106
    /**
107
     * Set whether this field is short enough for displaying
108
     * side-by-side with other fields.
109
     *
110
     * @param string $value
111
     * @return $this
112
     */
113 7
    public function setShort($value)
114
    {
115 7
        $this->short = (bool) $value;
116
117 7
        return $this;
118
    }
119
120
    /**
121
     * Get the array representation of this attachment field.
122
     *
123
     * @return array
124
     */
125 3
    public function toArray()
126
    {
127
        return [
128 3
            'title' => $this->getTitle(),
129 3
            'value' => $this->getValue(),
130 3
            'short' => $this->getShort(),
131
        ];
132
    }
133
}
134