Completed
Push — v2.0 ( c502f2...cf0b32 )
by Serhii
02:20
created

Device   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 4
1
<?php
2
/**
3
 * @author Sergey Nehaenko <[email protected]>
4
 * @license GPL
5
 * @copyright Sergey Nehaenko &copy 2016
6
 * @version 2.0
7
 * @project browser-detector
8
 */
9
10
namespace EndorphinStudio\Detector;
11
12
13
class Device extends Data
14
{
15
    /** @var string Model Name */
16
    public $ModelName = 'N\A';
17
18
    /**
19
     * Device constructor.
20
     * @param \SimpleXMLElement $xmlData Xml data from file
21
     */
22
    public function __construct($xmlData)
23
    {
24
        if($xmlData == null)
25
        {
26
            $this->Name = 'Desktop';
27
            $this->Type = 'desktop';
28
        }
29
        else
30
        {
31
            parent::__construct($xmlData);
32
33
            foreach ($xmlData->children() as $child)
34
            {
35
                switch ($child->getName()) {
36
                    case 'modelName':
37
                        $this->ModelName = $child->__toString();
38
                        break;
39
                }
40
            }
41
        }
42
    }
43
}