Image   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 45
ccs 10
cts 10
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 17 3
1
<?php
2
namespace Maknz\Slack\Block;
3
4
use Maknz\Slack\Block;
5
use Maknz\Slack\ImageTrait;
6
7
class Image extends Block
8
{
9
    use ImageTrait;
10
11
    /**
12
     * Block type.
13
     *
14
     * @var string
15
     */
16
    protected $type = 'image';
17
18
    /**
19
     * Internal attribute to property map.
20
     *
21
     * @var array
22
     */
23
    protected static $availableAttributes = [
24
        'image_url' => 'url',
25
        'alt_text'  => 'alt_text',
26
        'title'     => 'title',
27
        'block_id'  => 'block_id',
28
    ];
29
30
    /**
31
     * Convert the block to its array representation.
32
     *
33
     * @return array
34
     */
35 1
    public function toArray()
36
    {
37 1
        $data = [
38 1
            'type' => $this->getType(),
39 1
            'image_url' => $this->getUrl(),
40 1
            'alt_text' => $this->getAltText(),
41
        ];
42
43 1
        if ($this->getTitle()) {
44 1
            $data['title'] = $this->getTitle()->toArray();
45
        }
46
47 1
        if ($this->getBlockId()) {
48 1
            $data['block_id'] = $this->getBlockId();
49
        }
50
51 1
        return $data;
52
    }
53
}
54