Image   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 40
ccs 8
cts 8
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 13 2
1
<?php
2
namespace Maknz\Slack\BlockElement;
3
4
use Maknz\Slack\BlockElement;
5
use Maknz\Slack\ImageTrait;
6
7
class Image extends BlockElement
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
    ];
28
29
    /**
30
     * Convert the block to its array representation.
31
     *
32
     * @return array
33
     */
34 2
    public function toArray()
35
    {
36 2
        $data = [
37 2
            'type' => $this->getType(),
38 2
            'image_url' => $this->getUrl(),
39 2
            'alt_text' => $this->getAltText(),
40
        ];
41
42 2
        if ($this->getTitle()) {
43 1
            $data['title'] = $this->getTitle()->toArray();
44
        }
45
46 2
        return $data;
47
    }
48
}
49