BattleTheatreCollection::setItems()   D
last analyzed

Complexity

Conditions 10
Paths 2

Size

Total Lines 37
Code Lines 25

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 37
rs 4.8196
cc 10
eloc 25
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 BattleTheatreCollection 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['queue'] = function ($value) { return $value; };
32
        $converters['help'] = function ($value) { return $value; };
33
        $converters['description'] = function ($value) { return $value; };
34
        $converters['regions'] = function ($values) {
35
        // by Warringer\Types\Reference
36
        $func = function ($value) { return new Reference($value); };
37
38
            foreach ($values as $key => $value) {
39
                 $values[$key] = $func($value);
40
            }
41
           return $values;
42
        };
43
44
        $converters['key'] = function ($value) { return $value; };
45
        $converters['icon'] = function ($value) { return new Reference($value); };
46
        $converters['name'] = function ($value) { return $value; };
47
48
        $func = function ($value) use($converters) {
49
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
50
            $return['queue'] = isset($value->{'queue'}) ? $converters['queue']($value->{'queue'}) : null;
51
            $return['help'] = isset($value->{'help'}) ? $converters['help']($value->{'help'}) : null;
52
            $return['description'] = isset($value->{'description'}) ? $converters['description']($value->{'description'}) : null;
53
            $return['regions'] = isset($value->{'regions'}) ? $converters['regions']($value->{'regions'}) : null;
54
            $return['key'] = isset($value->{'key'}) ? $converters['key']($value->{'key'}) : null;
55
            $return['icon'] = isset($value->{'icon'}) ? $converters['icon']($value->{'icon'}) : null;
56
            $return['name'] = isset($value->{'name'}) ? $converters['name']($value->{'name'}) : null;
57
            return $return;
58
        };
59
60
        foreach ($items as $key => $value) {
61
            $this->items[$key] = $func($value);
62
        }
63
    }
64
65
    // by Warringer\Types\Long
66
    public function setTotalCount($totalCount)
67
    {
68
        $this->totalCount = $totalCount;
69
    }
70
71
    // by Warringer\Types\Reference
72
    public function setNext($next)
73
    {
74
        $this->next = new Reference($next);
75
    }
76
77
    // by Warringer\Types\Reference
78
    public function setPrevious($previous)
79
    {
80
        $this->previous = new Reference($previous);
81
    }
82
83
}
84