Completed
Push — master ( 69c79a...f44b26 )
by Adam
02:15
created

Helpers::isOs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Helpers.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:MobileDetect!
9
 * @subpackage     Templating
10
 * @since          1.0.0
11
 *
12
 * @date           16.06.14
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\MobileDetect\Templating;
18
19
use Nette;
20
21
use IPub;
22
use IPub\MobileDetect;
23
24
/**
25
 * Mobile detect template helpers
26
 *
27
 * @package        iPublikuj:MobileDetect!
28
 * @subpackage     Templating
29
 *
30
 * @author         Adam Kadlec <[email protected]>
31
 */
32 1
final class Helpers extends Nette\Object
33
{
34
	/**
35
	 * @var MobileDetect\MobileDetect
36
	 */
37
	private $mobileDetect;
38
39
	/**
40
	 * @var MobileDetect\Helpers\DeviceView
41
	 */
42
	private $deviceView;
43
44
	/**
45
	 * @param MobileDetect\MobileDetect $mobileDetect
46
	 * @param MobileDetect\Helpers\DeviceView $deviceView
47
	 */
48
	public function __construct(
49
		MobileDetect\MobileDetect $mobileDetect,
50
		MobileDetect\Helpers\DeviceView $deviceView
51
	) {
52 1
		$this->mobileDetect = $mobileDetect;
53 1
		$this->deviceView = $deviceView;
54 1
	}
55
56
	/**
57
	 * @return MobileDetect\MobileDetect
58
	 */
59
	public function getMobileDetectService() : MobileDetect\MobileDetect
60
	{
61 1
		return $this->mobileDetect;
62
	}
63
64
	/**
65
	 * @return MobileDetect\Helpers\DeviceView
66
	 */
67
	public function getDeviceViewService() : MobileDetect\Helpers\DeviceView
68
	{
69
		return $this->deviceView;
70
	}
71
72
	/**
73
	 * @return bool
74
	 */
75
	public function isMobile() : bool
76
	{
77 1
		return $this->mobileDetect->isMobile();
78
	}
79
80
	/**
81
	 * @return bool
82
	 */
83
	public function isPhone() : bool
84
	{
85
		return $this->mobileDetect->isPhone();
86
	}
87 1
88
	/**
89
	 * @return bool
90
	 */
91
	public function isTablet() : bool
92
	{
93
		return $this->mobileDetect->isTablet();
94
	}
95
96
	/**
97 1
	 * @param string $device
98
	 *
99
	 * @return bool
100
	 */
101
	public function isDevice(string $device) : bool
102
	{
103
		return $this->mobileDetect->is($device);
104
	}
105
106
	/**
107
	 * @param string $os
108
	 *
109
	 * @return bool
110
	 */
111
	public function isOs(string $os) : bool
112
	{
113
		return $this->mobileDetect->is($os);
114
	}
115
116
	/**
117
	 * @return bool
118
	 */
119
	public function isFullView() : bool
120
	{
121
		return $this->deviceView->isFullView();
122
	}
123
124
	/**
125
	 * @return bool
126
	 */
127
	public function isMobileView() : bool
128
	{
129
		return $this->deviceView->isMobileView();
130
	}
131
132
	/**
133
	 * @return bool
134
	 */
135
	public function isPhoneView() : bool
136
	{
137
		return $this->deviceView->isPhoneView();
138
	}
139 1
140
	/**
141
	 * @return bool
142
	 */
143
	public function isTabletView() : bool
144
	{
145
		return $this->deviceView->isTabletView();
146
	}
147
148
	/**
149
	 * @return bool
150
	 */
151
	public function isNotMobileView() : bool
152
	{
153
		return $this->deviceView->isNotMobileView();
154
	}
155
}
156