Passed
Push — master ( 8ede22...b3e0ce )
by Alexander
02:27
created

File::setExternalId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
namespace Maknz\Slack\Block;
3
4
use Maknz\Slack\Block;
5
6
class File extends Block
7
{
8
    /**
9
     * Block type.
10
     *
11
     * @var string
12
     */
13
    protected $type = 'file';
14
15
    /**
16
     * External identifier for the file.
17
     *
18
     * @var string
19
     */
20
    protected $external_id;
21
22
    /**
23
     * Source for the file.
24
     *
25
     * @var string
26
     */
27
    protected $source = 'remote';
28
29
    /**
30
     * Internal attribute to property map.
31
     *
32
     * @var array
33
     */
34
    protected static $availableAttributes = [
35
        'external_id' => 'external_id',
36
        'source'      => 'source',
37
        'block_id'    => 'block_id',
38
    ];
39
40
    /**
41
     * Get the external identifier for the file.
42
     *
43
     * @return string
44
     */
45 3
    public function getExternalId()
46
    {
47 3
        return $this->external_id;
48
    }
49
50
    /**
51
     * Set the external identifier for the file.
52
     *
53
     * @param string $externalId
54
     *
55
     * @return File
56
     */
57 3
    public function setExternalId($externalId)
58
    {
59 3
        $this->external_id = $externalId;
60
61 3
        return $this;
62
    }
63
64
    /**
65
     * Get the file source.
66
     *
67
     * @return string
68
     */
69 2
    public function getSource()
70
    {
71 2
        return $this->source;
72
    }
73
74
    /**
75
     * Set the file source.
76
     *
77
     * @param string $source
78
     *
79
     * @return File
80
     */
81 1
    public function setSource($source)
82
    {
83 1
        $this->source = $source;
84
85 1
        return $this;
86
    }
87
88
    /**
89
     * Convert the block to its array representation.
90
     *
91
     * @return array
92
     */
93 2
    public function toArray()
94
    {
95
        $data = [
96 2
            'type'        => $this->getType(),
97 2
            'external_id' => $this->getExternalId(),
98 2
            'source'      => $this->getSource(),
99
        ];
100
101 2
        if ($this->getBlockId()) {
102 1
            $data['block_id'] = $this->getBlockId();
103
        }
104
105 2
        return $data;
106
    }
107
}
108