MarketOrderCollection::setItems()   C
last analyzed

Complexity

Conditions 15
Paths 2

Size

Total Lines 40
Code Lines 33

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 40
rs 5.0504
cc 15
eloc 33
nc 2
nop 1

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace Perry\Representation\Eve\v1;
3
4
use \Perry\Representation\Reference as Reference;
5
use \Perry\Representation\Uri as Uri;
6
use \Perry\Representation\Base as Base;
7
8
class MarketOrderCollection extends Base
9
{
10
    public $pageCount;
11
12
    public $items = [];
13
14
    public $totalCount;
15
16
    public $next;
17
18
    public $previous;
19
20
    // by Warringer\Types\Long
21
    public function setPageCount($pageCount)
22
    {
23
        $this->pageCount = $pageCount;
24
    }
25
26
    // by Warringer\Types\ArrayType
27
    public function setItems($items)
28
    {
29
        // by Warringer\Types\Base
30
        $converters = [];
31
        $converters['buy'] = function ($value) { return $value; };
32
        $converters['issued'] = function ($value) { return $value; };
33
        $converters['price'] = function ($value) { return $value; };
34
        $converters['volumeEntered'] = function ($value) { return $value; };
35
        $converters['minVolume'] = function ($value) { return $value; };
36
        $converters['volume'] = function ($value) { return $value; };
37
        $converters['item'] = function ($value) { return new Reference($value); };
38
        $converters['range'] = function ($value) { return $value; };
39
        $converters['href'] = function ($value) { return new Uri($value); };
40
        $converters['location'] = function ($value) { return new Reference($value); };
41
        $converters['duration'] = function ($value) { return $value; };
42
        $converters['type'] = function ($value) { return new Reference($value); };
43
        $converters['id'] = function ($value) { return $value; };
44
45
        $func = function ($value) use($converters) {
46
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
47
            $return['buy'] = isset($value->{'buy'}) ? $converters['buy']($value->{'buy'}) : null;
48
            $return['issued'] = isset($value->{'issued'}) ? $converters['issued']($value->{'issued'}) : null;
49
            $return['price'] = isset($value->{'price'}) ? $converters['price']($value->{'price'}) : null;
50
            $return['volumeEntered'] = isset($value->{'volumeEntered'}) ? $converters['volumeEntered']($value->{'volumeEntered'}) : null;
51
            $return['minVolume'] = isset($value->{'minVolume'}) ? $converters['minVolume']($value->{'minVolume'}) : null;
52
            $return['volume'] = isset($value->{'volume'}) ? $converters['volume']($value->{'volume'}) : null;
53
            $return['item'] = isset($value->{'item'}) ? $converters['item']($value->{'item'}) : null;
54
            $return['range'] = isset($value->{'range'}) ? $converters['range']($value->{'range'}) : null;
55
            $return['href'] = isset($value->{'href'}) ? $converters['href']($value->{'href'}) : null;
56
            $return['location'] = isset($value->{'location'}) ? $converters['location']($value->{'location'}) : null;
57
            $return['duration'] = isset($value->{'duration'}) ? $converters['duration']($value->{'duration'}) : null;
58
            $return['type'] = isset($value->{'type'}) ? $converters['type']($value->{'type'}) : null;
59
            $return['id'] = isset($value->{'id'}) ? $converters['id']($value->{'id'}) : null;
60
            return $return;
61
        };
62
63
        foreach ($items as $key => $value) {
64
            $this->items[$key] = $func($value);
65
        }
66
    }
67
68
    // by Warringer\Types\Long
69
    public function setTotalCount($totalCount)
70
    {
71
        $this->totalCount = $totalCount;
72
    }
73
74
    // by Warringer\Types\Reference
75
    public function setNext($next)
76
    {
77
        $this->next = new Reference($next);
78
    }
79
80
    // by Warringer\Types\Reference
81
    public function setPrevious($previous)
82
    {
83
        $this->previous = new Reference($previous);
84
    }
85
86
}
87