Completed
Push — master ( 4a002f...a1b70a )
by Ezra
13s queued 10s
created

Item::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 14
cp 0
rs 9.552
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Syntax\SteamApi\Containers;
4
5
class Item extends BaseContainer
6
{
7
    public $id;
8
9
    public $originalId;
10
11
    public $defIndex;
12
13
    public $level;
14
15
    public $quality;
16
17
    public $quantity;
18
19
    public $inventory;
20
21
    public $origin;
22
23
    public $flags;
24
25
    public $containedItem;
26
27
    public $style;
28
29
    public $attributes;
30
31
    public $custom;
32
33
    public function __construct($item)
34
    {
35
        $this->id            = $item->id;
36
        $this->originalId    = $item->original_id;
37
        $this->defIndex      = $item->defindex;
38
        $this->level         = $item->level;
39
        $this->quality       = $item->quality;
40
        $this->quantity      = $item->quantity;
41
        $this->inventory     = $item->inventory;
42
        $this->origin        = $this->checkIssetField($item, 'origin');
43
        $this->containedItem = $this->checkIssetField($item, 'contained_item');
44
        $this->style         = $this->checkIssetField($item, 'style');
45
        $this->attributes    = $this->checkIssetField($item, 'attributes');
46
47
        $this->flags  = [
48
            'trade' => (boolean)! $this->checkIssetField($item, 'flag_cannot_trade', false),
49
            'craft' => (boolean)! $this->checkIssetField($item, 'flag_cannot_craft', false),
50
        ];
51
        $this->custom = [
52
            'name'        => $this->checkIssetField($item, 'custom_name'),
53
            'description' => $this->checkIssetField($item, 'custom_desc'),
54
        ];
55
    }
56
}
57