Completed
Push — 2.0.1 ( 3659a8 )
by Serhii
04:22
created

Data::__construct()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 10

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
cc 5
eloc 10
nc 5
nop 1
dl 16
loc 16
rs 8.8571
c 0
b 0
f 0
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
     * @return string
17
     */
18
    public function getName()
19
    {
20
        return $this->Name;
21
    }
22
23
    /**
24
     * @return string
25
     */
26
    public function getType()
27
    {
28
        return $this->Type;
29
    }
30
31
    /**
32
     * @param string $Name
33
     */
34
    public function setName($Name)
35
    {
36
        $this->Name = $Name;
37
    }
38
39
    /**
40
     * @param string $Type
41
     */
42
    public function setType($Type)
43
    {
44
        $this->Type = $Type;
45
    }
46
    /**
47
     * @var string Name
48
     */
49
    protected $Name = 'N\A';
50
    /** @var string Type */
51
    protected $Type = 'N\A';
52
53
    /**
54
     * Data constructor.
55
     * @param \SimpleXMLElement $xmlData Xml data from file
56
     */
57 View Code Duplication
    public function __construct(\SimpleXMLElement $xmlData)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        if($xmlData !== null)
60
        {
61
            foreach ($xmlData->children() as $child) {
62
                switch ($child->getName()) {
63
                    case 'name':
64
                        $this->Name = $child->__toString();
65
                        break;
66
                    case 'type':
67
                        $this->Type = $child->__toString();
68
                        break;
69
                }
70
            }
71
        }
72
    }
73
}
74