SovCampaignsCollection::setItems()   C
last analyzed

Complexity

Conditions 14
Paths 2

Size

Total Lines 50
Code Lines 36

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 50
rs 5.3716
cc 14
eloc 36
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 SovCampaignsCollection 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['campaignID'] = function ($value) { return $value; };
32
        $converters['eventType'] = function ($value) { return $value; };
33
        $converters['sourceSolarsystem'] = function ($value) { return $value; };
34
        $converters['attackers'] = function ($value) { return $value; };
35
        $converters['sourceItemID'] = function ($value) { return $value; };
36
        $converters['startTime'] = function ($value) { return $value; };
37
        $converters['scores'] = function ($values) {
38
        // by Warringer\Types\Dict
39
        $converters = [];
40
        $converters['score'] = function ($value) { return $value; };
41
        $converters['team'] = function ($value) { return $value; };
42
43
        $func = function ($value) use($converters) {
44
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
45
            $return['score'] = isset($value->{'score'}) ? $converters['score']($value->{'score'}) : null;
46
            $return['team'] = isset($value->{'team'}) ? $converters['team']($value->{'team'}) : null;
47
            return $return;
48
        };
49
50
            foreach ($values as $key => $value) {
51
                 $values[$key] = $func($value);
52
            }
53
           return $values;
54
        };
55
56
        $converters['defender'] = function ($value) { return $value; };
57
        $converters['constellation'] = function ($value) { return $value; };
58
59
        $func = function ($value) use($converters) {
60
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
61
            $return['campaignID'] = isset($value->{'campaignID'}) ? $converters['campaignID']($value->{'campaignID'}) : null;
62
            $return['eventType'] = isset($value->{'eventType'}) ? $converters['eventType']($value->{'eventType'}) : null;
63
            $return['sourceSolarsystem'] = isset($value->{'sourceSolarsystem'}) ? $converters['sourceSolarsystem']($value->{'sourceSolarsystem'}) : null;
64
            $return['attackers'] = isset($value->{'attackers'}) ? $converters['attackers']($value->{'attackers'}) : null;
65
            $return['sourceItemID'] = isset($value->{'sourceItemID'}) ? $converters['sourceItemID']($value->{'sourceItemID'}) : null;
66
            $return['startTime'] = isset($value->{'startTime'}) ? $converters['startTime']($value->{'startTime'}) : null;
67
            $return['scores'] = isset($value->{'scores'}) ? $converters['scores']($value->{'scores'}) : null;
68
            $return['defender'] = isset($value->{'defender'}) ? $converters['defender']($value->{'defender'}) : null;
69
            $return['constellation'] = isset($value->{'constellation'}) ? $converters['constellation']($value->{'constellation'}) : null;
70
            return $return;
71
        };
72
73
        foreach ($items as $key => $value) {
74
            $this->items[$key] = $func($value);
75
        }
76
    }
77
78
    // by Warringer\Types\Long
79
    public function setTotalCount($totalCount)
80
    {
81
        $this->totalCount = $totalCount;
82
    }
83
84
    // by Warringer\Types\Reference
85
    public function setNext($next)
86
    {
87
        $this->next = new Reference($next);
88
    }
89
90
    // by Warringer\Types\Reference
91
    public function setPrevious($previous)
92
    {
93
        $this->previous = new Reference($previous);
94
    }
95
96
}
97