Attachment   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 39
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toArray() 0 11 1
1
<?php
2
3
namespace Baguette\Mastodon\Entity;
4
5
/**
6
 * Attachment
7
 *
8
 * @author    USAMI Kenta <[email protected]>
9
 * @copyright 2017 Baguette HQ
10
 * @license   https://www.gnu.org/licenses/gpl-3.0.html GPL-3.0
11
 * @see https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#attachment
12
 * @property-read int    $id   ID of the attachment
13
 * @property-read string $type One of: "image", "video", "gifv"
14
 * @property-read string $url  URL of the locally hosted version of the image
15
 * @property-read string $remote_url  For remote images, the remote URL of the original image
16
 * @property-read string $preview_url URL of the preview image
17
 * @property-read string $text_url    Shorter URL for the image, for insertion into text (only present on local images)
18
 */
19
class Attachment extends Entity
20
{
21
    use \Teto\Object\TypedProperty;
22
23
    private static $property_types = [
0 ignored issues
show
Unused Code introduced by
The property $property_types is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
24
        'id'          => 'int',
25
        'type'        => 'enum',
26
        'url'         => 'string',
27
        'remote_url'  => 'string',
28
        'preview_url' => 'string',
29
        'text_url'    => 'string',
30
    ];
31
32
    private static $enum_values = [
0 ignored issues
show
Unused Code introduced by
The property $enum_values is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
33
        'type' => ['image', 'video', 'gifv'],
34
    ];
35
36 2
    public function __construct(array $properties)
37
    {
38 2
        $this->setProperties($properties);
39 2
    }
40
41
    /**
42
     * Returns attachment data as array
43
     *
44
     * @return array
45
     */
46 3
    public function toArray()
47
    {
48
        return [
49 3
            'id'          => $this->id,
50 3
            'type'        => $this->type,
51 3
            'url'         => $this->url,
52 3
            'remote_url'  => $this->remote_url,
53 3
            'preview_url' => $this->preview_url,
54 3
            'text_url'    => $this->text_url,
55
        ];
56
    }
57
}
58