AttachmentField::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 1
1
<?php
2
namespace Slack\Message;
3
4
use Slack\DataObject;
5
6
/**
7
 * A field inside a message attachment.
8
 *
9
 * @see https://api.slack.com/docs/attachments
10
 */
11
class AttachmentField extends DataObject
12
{
13
    /**
14
     * Creates a new attachment field.
15
     *
16
     * @param string $title A text heading for the field.
17
     * @param string $value The text value of the field.
18
     * @param bool $short Indicates if the value can be displayed side-by-side with other values.
19
     */
20 2
    public function __construct($title, $value, $short = true)
21
    {
22 2
        $this->data['title'] = $title;
23 2
        $this->data['value'] = $value;
24 2
        $this->data['short'] = $short;
25 2
    }
26
27
    /**
28
     * Gets the text heading for the field.
29
     *
30
     * @return string The text heading for the field.
31
     */
32 2
    public function getTitle()
33
    {
34 2
        return $this->data['title'];
35
    }
36
37
    /**
38
     * Gets the text value of the field.
39
     *
40
     * @return string The text value of the field.
41
     */
42 2
    public function getValue()
43
    {
44 2
        return $this->data['value'];
45
    }
46
47
    /**
48
     * Checks if the value can be displayed side-by-side with other values.
49
     *
50
     * @return bool True if the value is short, otherwise false.
51
     */
52 2
    public function isShort()
53
    {
54 2
        return isset($this->data['short']) && (bool)$this->data['short'];
55
    }
56
}
57