Completed
Push — master ( 2dbf9c...287c2f )
by Sullivan
21:25 queued 07:13
created

AttachmentField::isShort()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Nexylan packages.
7
 *
8
 * (c) Nexylan SAS <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Nexy\Slack;
15
16
/**
17
 * @author Sullivan Senechal <[email protected]>
18
 */
19
final class AttachmentField
20
{
21
    /**
22
     * The required title field of the field.
23
     *
24
     * @var string
25
     */
26
    private $title;
27
28
    /**
29
     * The required value of the field.
30
     *
31
     * @var string
32
     */
33
    private $value;
34
35
    /**
36
     * Whether the value is short enough to fit side by side with
37
     * other values.
38
     *
39
     * @var bool
40
     */
41
    private $short;
42
43
    /**
44
     * @param string $title
45
     * @param string $value
46
     * @param bool   $short
47
     */
48
    public function __construct(string $title, string $value, bool $short = false)
49
    {
50
        $this->title = $title;
51
        $this->value = $value;
52
        $this->short = $short;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getTitle(): string
59
    {
60
        return $this->title;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getValue(): string
67
    {
68
        return $this->value;
69
    }
70
71
    /**
72
     * @return bool
73
     */
74
    public function isShort(): bool
75
    {
76
        return $this->short;
77
    }
78
79
    /**
80
     * Get the array representation of this attachment field.
81
     *
82
     * @return array
83
     */
84
    public function toArray()
85
    {
86
        return [
87
            'title' => $this->title,
88
            'value' => $this->value,
89
            'short' => $this->short,
90
        ];
91
    }
92
}
93