ArtworkItem   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 121
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 37 5
1
<?php
2
3
4
namespace Inktale\Api\Structures;
5
6
7
class ArtworkItem extends AbstractBaseItem
8
{
9
    /**
10
     * @var string
11
     */
12
    public $artworkId;
13
14
    /**
15
     * Display name
16
     *
17
     * @var string
18
     */
19
    public $name;
20
21
    /**
22
     * Is publicly visible
23
     *
24
     * @var bool
25
     */
26
    public $isPublic;
27
28
    /**
29
     * Is processing files or products
30
     *
31
     * @var bool
32
     */
33
    public $isProcessing;
34
35
    /**
36
     * Public description
37
     *
38
     * @var string
39
     */
40
    public $description;
41
42
    /**
43
     * Public URL to artwork page
44
     *
45
     * @var string
46
     */
47
    public $url;
48
49
    /**
50
     * List of keywords
51
     *
52
     * @var string[]
53
     */
54
    public $keywords;
55
56
    /**
57
     * Main artwork file (displayed in artwork public page)
58
     * If artwork is still processing, this value can be missing
59
     *
60
     * @var ArtworkFileItem
61
     */
62
    public $mainArtworkFile;
63
64
    /**
65
     * List of additional artwork files throughout all products (if set)
66
     * If artwork is still processing, values can be missing
67
     *
68
     * @var ArtworkFileItem[]
69
     */
70
    public $artworkFiles = [];
71
72
    /**
73
     * Artwork products currently enabled
74
     *
75
     * @var ArtworkProductItem[]
76
     */
77
    public $artworkProducts = [];
78
79
    /**
80
     * Unix timestamp
81
     *
82
     * @var int
83
     */
84
    public $createdAt;
85
86
    /**
87
     * @param array|mixed $raw
88
     * @return ArtworkItem
89
     */
90
    static function fromArray($raw)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
91
    {
92
        $item = new self;
93
94
        $item->raw = $raw;
0 ignored issues
show
Documentation Bug introduced by
It seems like $raw of type * is incompatible with the declared type array of property $raw.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
95
96
        $item->artworkId = $raw['artworkId'];
97
        $item->name = $raw['name'];
98
        $item->isPublic = (bool)$raw['isPublic'];
99
        $item->isProcessing = (bool)$raw['isProcessing'];
100
        if (isset($raw['description'])) {
101
            $item->description = $raw['description'];
102
        }
103
        $item->url = $raw['url'];
104
105
        if (isset($raw['keywords'])) {
106
            $item->keywords = $raw['keywords'];
107
        }
108
109
        $item->mainArtworkFile = ArtworkFileItem::fromArray($raw['mainArtworkFile']);
110
111
        if (isset($raw['artworkFiles'])) {
112
            $item->artworkFiles = array_map(function ($v) {
113
                return ArtworkFileItem::fromArray($v);
114
            }, $raw['artworkFiles']);
115
        }
116
117
        if (isset($raw['artworkProducts'])) {
118
            $item->artworkProducts = array_map(function ($v) {
119
                return ArtworkProductItem::fromArray($v);
120
            }, $raw['artworkProducts']);
121
        }
122
123
        $item->createdAt = (int)$raw['createdAt'];
124
125
        return $item;
126
    }
127
}