BloodlineCollection::setItems()   C
last analyzed

Complexity

Conditions 8
Paths 2

Size

Total Lines 26
Code Lines 19

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 26
rs 5.3846
cc 8
eloc 19
nc 2
nop 1
1
<?php
2
namespace Perry\Representation\Eve\v2;
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 BloodlineCollection 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['race'] = function ($value) { return new Reference($value); };
32
        $converters['description'] = function ($value) { return $value; };
33
        $converters['name'] = function ($value) { return $value; };
34
        $converters['href'] = function ($value) { return new Uri($value); };
35
        $converters['id'] = function ($value) { return $value; };
36
        $converters['icon'] = function ($value) { return new Reference($value); };
37
38
        $func = function ($value) use($converters) {
39
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
40
            $return['race'] = isset($value->{'race'}) ? $converters['race']($value->{'race'}) : null;
41
            $return['description'] = isset($value->{'description'}) ? $converters['description']($value->{'description'}) : null;
42
            $return['name'] = isset($value->{'name'}) ? $converters['name']($value->{'name'}) : null;
43
            $return['href'] = isset($value->{'href'}) ? $converters['href']($value->{'href'}) : null;
44
            $return['id'] = isset($value->{'id'}) ? $converters['id']($value->{'id'}) : null;
45
            $return['icon'] = isset($value->{'icon'}) ? $converters['icon']($value->{'icon'}) : null;
46
            return $return;
47
        };
48
49
        foreach ($items as $key => $value) {
50
            $this->items[$key] = $func($value);
51
        }
52
    }
53
54
    // by Warringer\Types\Long
55
    public function setTotalCount($totalCount)
56
    {
57
        $this->totalCount = $totalCount;
58
    }
59
60
    // by Warringer\Types\Reference
61
    public function setNext($next)
62
    {
63
        $this->next = new Reference($next);
64
    }
65
66
    // by Warringer\Types\Reference
67
    public function setPrevious($previous)
68
    {
69
        $this->previous = new Reference($previous);
70
    }
71
72
}
73