Passed
Pull Request — master (#17)
by ARCANEDEV
05:21
created

FileItem   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 18
c 1
b 0
f 0
dl 0
loc 53
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A type() 0 3 1
A load() 0 7 1
A toArray() 0 8 1
1
<?php namespace Arcanesoft\Media\Entities;
2
3
/**
4
 * Class     FileItem
5
 *
6
 * @package  Arcanesoft\Media\Entities
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
class FileItem extends MediaItem
10
{
11
    /* -----------------------------------------------------------------
12
     |  Properties
13
     | -----------------------------------------------------------------
14
     */
15
16
    public $url;
17
    public $mimetype;
18
    public $lastModified;
19
    public $visibility;
20
    public $size;
21
22
    /* -----------------------------------------------------------------
23
     |  Main Methods
24
     | -----------------------------------------------------------------
25
     */
26
27
    protected function load(array $data, string $path)
28
    {
29
        $this->url          = $data['url'];
30
        $this->mimetype     = $data['mimetype'];
31
        $this->lastModified = $data['lastModified'];
32
        $this->visibility   = $data['visibility'];
33
        $this->size         = $data['size'];
34
    }
35
36
    /* -----------------------------------------------------------------
37
     |  Getters
38
     | -----------------------------------------------------------------
39
     */
40
41
    /**
42
     * Get the item type.
43
     *
44
     * @return mixed
45
     */
46
    public function type(): string
47
    {
48
        return static::TYPE_FILE;
49
    }
50
51
    /**
52
     * @return array
53
     */
54
    public function toArray(): array
55
    {
56
        return array_merge(parent::toArray(), [
57
            'url'          => $this->url,
58
            'mimetype'     => $this->mimetype,
59
            'lastModified' => $this->lastModified,
60
            'visibility'   => $this->visibility,
61
            'size'         => $this->size,
62
        ]);
63
    }
64
}
65