Completed
Push — master ( 23164c...fde7a4 )
by Serhii
03:04 queued 01:10
created

OS::__construct()   C

Complexity

Conditions 7
Paths 7

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 17
nc 7
nop 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 OS extends DataWithVersion
14
{
15
    /** @var string $Family */
16
    public $Family = D_NA;
17
18
    /**
19
     * OS constructor.
20
     * @param \SimpleXMLElement $xmlData Xml data from file
21
     */
22
    public function __construct(\SimpleXMLElement $xmlData)
23
    {
24
        parent::__construct($xmlData);
25
        if($xmlData !== null)
26
        {
27
            foreach ($xmlData->children() as $child) {
28
                switch ($child->getName()) {
29
                    case 'family':
30
                        switch ($child->__toString()) {
31
                            case 'UNX':
32
                                $this->Family = UNX;
33
                                break;
34
                            case 'MC':
35
                                $this->Family = MC;
36
                                break;
37
                            case 'WIN':
38
                                $this->Family = WIN;
39
                                break;
40
                        }
41
                        break;
42
                }
43
            }
44
        }
45
    }
46
47
    public static function initEmpty()
48
    {
49
        return new self(new \SimpleXMLElement('<null>null</null>'));
50
    }
51
52
}
53
54
define('UNX','unix');
55
define('WIN','windows');
56
define('MC','mac');
57