AttachmentField::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
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
    public function __construct(string $title, string $value, bool $short = false)
44
    {
45
        $this->title = $title;
46
        $this->value = $value;
47
        $this->short = $short;
48
    }
49
50
    public function getTitle(): string
51
    {
52
        return $this->title;
53
    }
54
55
    public function getValue(): string
56
    {
57
        return $this->value;
58
    }
59
60
    public function isShort(): bool
61
    {
62
        return $this->short;
63
    }
64
65
    /**
66
     * Get the array representation of this attachment field.
67
     */
68
    public function toArray(): array
69
    {
70
        return [
71
            'title' => $this->title,
72
            'value' => $this->value,
73
            'short' => $this->short,
74
        ];
75
    }
76
}
77