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

FileItem::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 2
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