Sysinfo   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 11
c 3
b 1
f 1
lcom 1
cbo 1
dl 0
loc 82
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C xmlDeserialize() 0 38 11
1
<?php
2
3
namespace Xdaysaysay\CoreBundle\XmlMapping;
4
5
use Sabre\Xml\Element\KeyValue;
6
use Sabre\Xml\Reader;
7
use Sabre\Xml\XmlDeserializable;
8
9
class Sysinfo implements XmlDeserializable
10
{
11
    /**
12
     * @var Slots
13
     */
14
    public $slots;
15
16
    /**
17
     * @var Mainqueue
18
     */
19
    public $mainqueue;
20
21
    /**
22
     * @var Idlequeue
23
     */
24
    public $idlequeue;
25
26
    /**
27
     * @var Bandwidth
28
     */
29
    public $bandwidth;
30
31
    /**
32
     * @var Quota
33
     */
34
    public $quota;
35
36
    /**
37
     * @var Limits
38
     */
39
    public $limits;
40
41
    /**
42
     * @var Network[]
43
     */
44
    public $networks;
45
46
    /**
47
     * @var Stats
48
     */
49
    public $stats;
50
51
    public static function xmlDeserialize(Reader $reader)
52
    {
53
        $sysinfo = new self();
54
55
        // Borrowing a parser from the KeyValue class.
56
        $children = $reader->parseInnerTree();
57
        if(is_array($children)) {
58
            foreach ($children as $child) {
59
                if ($child['name'] === '{}slots') {
60
                    $sysinfo->slots = $child['value'];
61
                }
62
                if ($child['name'] === '{}mainqueue') {
63
                    $sysinfo->mainqueue = $child['value'];
64
                }
65
                if ($child['name'] === '{}idlequeue') {
66
                    $sysinfo->idlequeue = $child['value'];
67
                }
68
                if ($child['name'] === '{}bandwidth') {
69
                    $sysinfo->bandwidth = $child['value'];
70
                }
71
                if ($child['name'] === '{}quota') {
72
                    $sysinfo->quota = $child['value'];
73
                }
74
                if ($child['name'] === '{}limits') {
75
                    $sysinfo->limits = $child['value'];
76
                }
77
                if ($child['name'] === '{}network') {
78
                    $sysinfo->networks[] = $child['value'];
79
                }
80
                if ($child['name'] === '{}stats') {
81
                    $sysinfo->stats = $child['value'];
82
                }
83
            }
84
        }
85
86
87
        return $sysinfo;
88
    }
89
90
}