Completed
Push — master ( e814e0...e87053 )
by Mārtiņš
01:53
created

ArtworkFileItem::fromArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
4
namespace Inktale\Api\Structures;
5
6
7
class ArtworkFileItem extends AbstractBaseItem
8
{
9
    const STATUS_PROCESSING = 'processing';
10
    const STATUS_FAILED = 'failed';
11
    const STATUS_OK = 'ok';
12
13
    /**
14
     * One of the statuses defined
15
     *
16
     * @var string
17
     */
18
    public $status;
19
20
    /**
21
     * If image has failed, reason given here
22
     *
23
     * @var string
24
     */
25
    public $reasonFailed;
26
27
    /**
28
     * @var string
29
     */
30
    public $urlLarge;
31
32
    /**
33
     * @var string
34
     */
35
    public $urlMedium;
36
37
    /**
38
     * @param array|mixed $raw
39
     * @return ArtworkFileItem|null
40
     */
41
    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...
42
    {
43
        if(!$raw){
44
            return null;
45
        }
46
47
        $item = new self;
48
49
        $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...
50
51
        $item->status = $raw['status'];
52
        $item->reasonFailed = $raw['reasonFailed'];
53
        $item->urlLarge = $raw['urlLarge'];
54
        $item->urlMedium = $raw['urlMedium'];
55
56
        return $item;
57
    }
58
}