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

ProductItem::fromArray()   A

Complexity

Conditions 1
Paths 1

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 1
eloc 8
nc 1
nop 1
1
<?php
2
3
4
namespace Inktale\Api\Structures;
5
6
7
class ProductItem extends AbstractBaseItem
8
{
9
    /**
10
     * Unique product identifier, used to reference products (shirt, mug, etc)
11
     *
12
     * @var string
13
     */
14
    public $productType;
15
16
    /**
17
     * @var string
18
     */
19
    public $title;
20
21
    /**
22
     * Base price in USD (informative, not for calculating prices)
23
     *
24
     * @var float
25
     */
26
    public $price;
27
28
    /**
29
     * Suggested selling price in USD based on base price.
30
     *
31
     * @var float
32
     */
33
    public $sellingPrice;
34
35
    /**
36
     * @param array|mixed $raw
37
     * @return ProductItem
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->productType = $raw['productType'];
46
        $item->title = $raw['title'];
47
        $item->price = (float)$raw['price'];
48
        $item->sellingPrice = (float)$raw['sellingPrice'];
49
50
        return $item;
51
    }
52
}