Completed
Push — master ( 8ae406...7a819f )
by Mārtiņš
01:47
created

StoreItem::fromArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
4
namespace Inktale\Api\Structures;
5
6
7
class StoreItem extends AbstractBaseItem
8
{
9
    /**
10
     * @var string
11
     */
12
    public $storeId;
13
14
    /**
15
     * Public store name
16
     *
17
     * @var string
18
     */
19
    public $name;
20
21
    /**
22
     * Public store URL
23
     *
24
     * @var string
25
     */
26
    public $url;
27
28
    /**
29
     * Optional Api key. Is available only after store creation call, otherwise empty.
30
     *
31
     * @var null|string
32
     */
33
    public $apiKey;
34
35
    /**
36
     * @param array|mixed $raw
37
     * @return StoreItem
38
     */
39
    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...
40
    {
41
        $item = new self;
42
43
        $item->rawData = $raw;
0 ignored issues
show
Documentation Bug introduced by
It seems like $raw of type * is incompatible with the declared type array of property $rawData.

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...
44
45
        $item->storeId = $raw['storeId'];
46
        $item->name = $raw['name'];
47
        $item->url = $raw['url'];
48
        $item->apiKey = !empty($raw['apiKey']) ? $raw['apiKey'] : null;
49
50
        return $item;
51
    }
52
}