AttachmentField   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 46
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getTitle() 0 4 1
A getValue() 0 4 1
A isShort() 0 4 2
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