Passed
Push — master ( 9edc41...f34eb1 )
by Adam
03:33
created

Helpers::getDeviceViewService()   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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 1
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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
33
{
34
	/**
35
	 * Implement nette smart magic
36
	 */
37 1
	use Nette\SmartObject;
38
39
	/**
40
	 * @var MobileDetect\MobileDetect
41
	 */
42
	private $mobileDetect;
43
44
	/**
45
	 * @var MobileDetect\Helpers\DeviceView
46
	 */
47
	private $deviceView;
48
49
	/**
50
	 * @param MobileDetect\MobileDetect $mobileDetect
51
	 * @param MobileDetect\Helpers\DeviceView $deviceView
52
	 */
53
	public function __construct(
54
		MobileDetect\MobileDetect $mobileDetect,
55
		MobileDetect\Helpers\DeviceView $deviceView
56
	) {
57 1
		$this->mobileDetect = $mobileDetect;
58 1
		$this->deviceView = $deviceView;
59 1
	}
60
61
	/**
62
	 * @return MobileDetect\MobileDetect
63
	 */
64
	public function getMobileDetectService() : MobileDetect\MobileDetect
65
	{
66
		return $this->mobileDetect;
67
	}
68
69
	/**
70
	 * @return MobileDetect\Helpers\DeviceView
71
	 */
72
	public function getDeviceViewService() : MobileDetect\Helpers\DeviceView
73
	{
74
		return $this->deviceView;
75
	}
76
77
	/**
78
	 * @return bool
79
	 */
80
	public function isMobile() : bool
81
	{
82 1
		return $this->mobileDetect->isMobile();
83
	}
84
85
	/**
86
	 * @return bool
87
	 */
88
	public function isPhone() : bool
89
	{
90
		return $this->mobileDetect->isPhone();
91
	}
92
93
	/**
94
	 * @return bool
95
	 */
96
	public function isTablet() : bool
97
	{
98 1
		return $this->mobileDetect->isTablet();
99
	}
100
101
	/**
102
	 * @param string $device
103
	 *
104
	 * @return bool
105
	 */
106
	public function isDevice(string $device) : bool
107
	{
108 1
		return $this->mobileDetect->is($device);
109
	}
110
111
	/**
112
	 * @param string $os
113
	 *
114
	 * @return bool
115
	 */
116
	public function isOs(string $os) : bool
117
	{
118 1
		return $this->mobileDetect->is($os);
119
	}
120
121
	/**
122
	 * @return bool
123
	 */
124
	public function isFullView() : bool
125
	{
126
		return $this->deviceView->isFullView();
127
	}
128
129
	/**
130
	 * @return bool
131
	 */
132
	public function isMobileView() : bool
133
	{
134
		return $this->deviceView->isMobileView();
135
	}
136
137
	/**
138
	 * @return bool
139
	 */
140
	public function isPhoneView() : bool
141
	{
142
		return $this->deviceView->isPhoneView();
143
	}
144
145
	/**
146
	 * @return bool
147
	 */
148
	public function isTabletView() : bool
149
	{
150
		return $this->deviceView->isTabletView();
151
	}
152
153
	/**
154
	 * @return bool
155
	 */
156
	public function isNotMobileView() : bool
157
	{
158
		return $this->deviceView->isNotMobileView();
159
	}
160
}
161