Passed
Push — master ( 5649e5...cd00c2 )
by Joshua
05:29 queued 03:33
created

Asset::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 1
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the -SeamsCMSDeliverySdk package.
7
 *
8
 * (c) Seams-CMS.com
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace SeamsCMS\Delivery\Model;
15
16
/**
17
 * Class Asset
18
 * @package SeamsCMS\Delivery\Model
19
 */
20
class Asset
21
{
22
    use HydratorTrait {
23
        fromArray as private fromArrayTrait;
24
    }
25
26
    /** @var string */
27
    private $link;
28
    /** @var string|null */
29
    private $thumbnailLink;
30
    /** @var int */
31
    private $size;
32
    /** @var string */
33
    private $path;
34
    /** @var string */
35
    private $title;
36
    /** @var string */
37
    private $mimetype;
38
    /** @var string */
39
    private $workspace;
40
    /** @var AssetMeta */
41
    private $meta;
42
43
    /**
44
     * Asset constructor.
45
     *
46
     */
47 5
    protected function __construct() {
48 5
    }
49
50
    /**
51
     * @return string
52
     */
53 1
    public function getLink(): string
54
    {
55 1
        return $this->link;
56
    }
57
58
    /**
59
     * @return string|null
60
     */
61 1
    public function getThumbnailLink()
62
    {
63 1
        return $this->thumbnailLink;
64
    }
65
66
    /**
67
     * @return int
68
     */
69 1
    public function getSize(): int
70
    {
71 1
        return $this->size;
72
    }
73
74
    /**
75
     * @return string
76
     */
77 5
    public function getPath(): string
78
    {
79 5
        return $this->path;
80
    }
81
82
    /**
83
     * @return string
84
     */
85 1
    public function getTitle(): string
86
    {
87 1
        return $this->title;
88
    }
89
90
    /**
91
     * @return string
92
     */
93 1
    public function getMimetype(): string
94
    {
95 1
        return $this->mimetype;
96
    }
97
98
    /**
99
     * @return string
100
     */
101 5
    public function getWorkspace(): string
102
    {
103 5
        return $this->workspace;
104
    }
105
106
    /**
107
     * @return AssetMeta
108
     */
109 1
    public function getMeta(): AssetMeta
110
    {
111 1
        return $this->meta;
112
    }
113
114
    /**
115
     * @param array $data
116
     * @return Asset
117
     */
118 8
    public static function fromArray(array $data)
119
    {
120 8
        if (! isset($data['meta']) || ! isset($data['asset'])) {
121 3
            throw new \InvalidArgumentException("Need both 'meta' and 'asset'");
122
        }
123
124 5
        $meta = AssetMeta::fromArray($data['meta']);
125 5
        $data = $data['asset'];
126 5
        $data['meta'] = $meta;
127
128 5
        return self::fromArrayTrait($data);
129
    }
130
}
131