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

Robot   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 15
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 90
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getHomepage() 0 4 1
A isSearchEngine() 0 4 1
A getOwner() 0 4 1
A setHomepage() 0 4 1
A setOwner() 0 4 1
A setSearchEngine() 0 4 1
A initEmpty() 0 4 1
C __construct() 0 26 8
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 Robot extends Data
14
{
15
    /**
16
     * @return string
17
     */
18
    public function getHomepage()
19
    {
20
        return $this->Homepage;
21
    }
22
23
    /**
24
     * @return boolean
25
     */
26
    public function isSearchEngine()
27
    {
28
        return $this->SearchEngine;
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getOwner()
35
    {
36
        return $this->Owner;
37
    }
38
39
    /**
40
     * @param string $Homepage
41
     */
42
    public function setHomepage($Homepage)
43
    {
44
        $this->Homepage = $Homepage;
45
    }
46
47
    /**
48
     * @param string $Owner
49
     */
50
    public function setOwner($Owner)
51
    {
52
        $this->Owner = $Owner;
53
    }
54
55
    /**
56
     * @param boolean $isSearchEngine
57
     */
58
    public function setSearchEngine($isSearchEngine)
59
    {
60
        $this->SearchEngine = $isSearchEngine;
61
    }
62
    /** @var string Crawler homepage */
63
    private $Homepage = D_NA;
64
65
    /** @var boolean Search Engine */
66
    private $SearchEngine = false;
67
68
    /** @var string Crawler Owner */
69
    private $Owner = D_NA;
70
71
    public function __construct(\SimpleXMLElement $xmlData)
72
    {
73
        parent::__construct($xmlData);
74
75
        if($xmlData !== null)
76
        {
77
            foreach ($xmlData->children() as $child)
78
            {
79
                $name = $child->getName();
80
                $val = $child->__toString();
81
                if($name != 'id' && $name != 'pattern' && $name != 'SearchEngine')
82
                {
83
                    $this->$name = $val;
84
                }
85
                if($name == 'SearchEngine')
86
                {
87
                    if($val == 'true')
88
                    {
89
                        $this->setSearchEngine(true);
90
                    }
91
                    else
92
                        $this->setSearchEngine(false);
93
                }
94
            }
95
        }
96
    }
97
98
    public static function initEmpty()
99
    {
100
        return new self(new \SimpleXMLElement('<null>null</null>'));
101
    }
102
}
103