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

Data::__construct()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 8.8571
cc 5
eloc 10
nc 5
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 Data
14
{
15
    /**
16
     * @var string Name
17
     */
18
    public $Name = 'N\A';
19
    /** @var string Type */
20
    public $Type = 'N\A';
21
22
    /**
23
     * Data constructor.
24
     * @param \SimpleXMLElement $xmlData Xml data from file
25
     */
26
    public function __construct($xmlData)
27
    {
28
        if($xmlData != null)
29
        {
30
            foreach ($xmlData->children() as $child) {
31
                switch ($child->getName()) {
32
                    case 'name':
33
                        $this->Name = $child->__toString();
34
                        break;
35
                    case 'type':
36
                        $this->Type = $child->__toString();
37
                        break;
38
                }
39
            }
40
        }
41
    }
42
43
}