Completed
Branch 3.0.0 (3f0ab7)
by Serhii
03:15
created

Device   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 38
rs 10
wmc 6
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 23 5
A initEmpty() 0 4 1
1
<?php
2
/**
3
 * @author Sergey Nehaenko <[email protected]>
4
 * @license GPL
5
 * @copyright Sergey Nehaenko &copy 2016
6
 * @version 3.0.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 = D_NA;
17
18
    /**
19
     * Device constructor.
20
     * @param \SimpleXMLElement $xmlData Xml data from file
21
     */
22
    public function __construct(\SimpleXMLElement $xmlData)
23
    {
24
        if($xmlData === null || $xmlData->getName() == 'null')
25
        {
26
            parent::__construct($xmlData);
27
28
            $this->setName('Desktop');
29
            $this->setType('desktop');
30
        }
31
        else
32
        {
33
            parent::__construct($xmlData);
34
35
            foreach ($xmlData->children() as $child)
36
            {
37
                switch ($child->getName()) {
38
                    case 'modelName':
39
                        $this->ModelName = $child->__toString();
40
                        break;
41
                }
42
            }
43
        }
44
    }
45
46
    public static function initEmpty()
47
    {
48
        return new self(new \SimpleXMLElement('<null>null</null>'));
49
    }
50
}
51