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

OS::__construct()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

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