1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Sergey Nehaenko <[email protected]> |
4
|
|
|
* @license GPL |
5
|
|
|
* @copyright Sergey Nehaenko © 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
|
|
|
|