Completed
Branch master (d2c4e1)
by
unknown
09:55 waited 07:09
created

Client::_getDeviceArray()   A

↳ Parent: Client

Complexity

Conditions 3
Paths 3

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 15
Code Lines 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
1
<?php
2
namespace Redaxscript\Template\Helper;
3
4
/**
5
 * helper class to provide a client helper
6
 *
7
 * @since 3.0.0
8
 *
9
 * @package Redaxscript
10
 * @category Template
11
 * @author Henry Ruhs
12
 */
13
14
class Client extends HelperAbstract
15
{
16
	/**
17
	 * array of devices
18
	 *
19
	 * @var array
20
	 */
21
22
	protected $_deviceArray =
23
	[
24
		'mobile' => 'myMobile',
25
		'tablet' => 'myTablet',
26
		'desktop' => 'myDesktop'
27
	];
28
29
	/**
30
	 * process
31
	 *
32
	 * @since 3.0.0
33
	 *
34
	 * @return string
35
	 */
36
37
	public function process()
38
	{
39
		return  array_unique(array_merge(
40
			$this->_getBrowserArray(),
41
			$this->_getDeviceArray()
42
		));
43
	}
44
45
	/**
46
	 * get the browser array
47
	 *
48
	 * @since 3.0.0
49
	 *
50
	 * @return array
51
	 */
52
53
	protected function _getBrowserArray()
54
	{
55
		return
56
		[
57
			$this->_registry->get('myBrowser'),
58
			$this->_registry->get('myBrowserVersion'),
59
			$this->_registry->get('myEngine')
60
		];
61
	}
62
63
	/**
64
	 * get the device array
65
	 *
66
	 * @since 3.0.0
67
	 *
68
	 * @return array
69
	 */
70
71
	protected function _getDeviceArray()
72
	{
73
		foreach ($this->_deviceArray as $system => $value)
74
		{
75
			$device = $this->_registry->get($value);
76
			if ($device)
77
			{
78
				return
79
				[
80
					$system,
81
					$device
82
				];
83
			}
84
		}
85
	}
86
}
87