1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* (c) 2008 Dejan Spasic <[email protected]> |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @package Util |
9
|
|
|
* @subpackage UserAgentParser |
10
|
|
|
* @author Dejan Spasic <[email protected]> |
11
|
|
|
* @version GIT: $Id:$ |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Fam\Util\UserAgentParser; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Represents a user agent |
18
|
|
|
* |
19
|
|
|
* @package Util |
20
|
|
|
* @subpackage UserAgentParser |
21
|
|
|
* @author Dejan Spasic <[email protected]> |
22
|
|
|
* @version @@PACKAGE_VERSION@@ |
23
|
|
|
*/ |
24
|
|
|
class UserAgent |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var OperatingSystem |
28
|
|
|
*/ |
29
|
|
|
private $operatingSystem; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var WebClient |
33
|
|
|
*/ |
34
|
|
|
private $webClient; |
35
|
|
|
|
36
|
15 |
|
public function __construct(OperatingSystem $operatingSystem, WebClient $webClient) |
37
|
|
|
{ |
38
|
15 |
|
$this->operatingSystem = $operatingSystem; |
39
|
15 |
|
$this->webClient = $webClient; |
40
|
15 |
|
} |
41
|
|
|
|
42
|
3 |
|
public function os(): string |
43
|
|
|
{ |
44
|
3 |
|
return $this->operatingSystem->getName(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param string|OperatingSystem $operatingSystem |
49
|
|
|
* @return bool |
50
|
|
|
*/ |
51
|
2 |
|
public function isOs($operatingSystem): bool |
52
|
|
|
{ |
53
|
2 |
|
return $this->operatingSystem->equals($operatingSystem); |
54
|
|
|
} |
55
|
|
|
|
56
|
3 |
|
public function webClient(): string |
57
|
|
|
{ |
58
|
3 |
|
return $this->webClient->getName(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param string|WebClient $webClient |
63
|
|
|
* @return boolean |
64
|
|
|
*/ |
65
|
2 |
|
public function isWebClient($webClient): bool |
66
|
|
|
{ |
67
|
2 |
|
return $this->webClient->isNameEquals($webClient); |
68
|
|
|
} |
69
|
|
|
|
70
|
1 |
|
public function webClientVersion(): string |
71
|
|
|
{ |
72
|
1 |
|
return $this->webClient->getVersion(); |
73
|
|
|
} |
74
|
|
|
|
75
|
2 |
|
public function isWebClientVersion(string $webClientVersion): bool |
76
|
|
|
{ |
77
|
2 |
|
return $this->webClient->isVersionEquals($webClientVersion); |
78
|
|
|
} |
79
|
|
|
|
80
|
2 |
|
public function isWebClientVersionBetween(string $lowerVersion, string $greaterVersion): bool |
81
|
|
|
{ |
82
|
2 |
|
return $this->webClient->isVersionBetween($lowerVersion, $greaterVersion); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|