Direction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 50
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 3
1
<?php
2
namespace Redaxscript\Template\Helper;
3
4
use function in_array;
5
6
/**
7
 * helper class to provide a direction helper
8
 *
9
 * @since 3.0.0
10
 *
11
 * @package Redaxscript
12
 * @category Template
13
 * @author Henry Ruhs
14
 */
15
16
class Direction extends HelperAbstract
17
{
18
	/**
19
	 * default direction
20
	 *
21
	 * @var string
22
	 */
23
24
	protected $_direction = 'ltr';
25
26
	/**
27
	 * array of the directions
28
	 *
29
	 * @var array
30
	 */
31
32
	protected $_directionArray =
33
	[
34
		'rtl' =>
35
		[
36
			'ar',
37
			'fa',
38
			'he'
39
		]
40
	];
41
42
	/**
43
	 * process
44
	 *
45
	 * @since 3.0.0
46
	 *
47
	 * @return string|null
48
	 */
49
50 3
	public function process() : ?string
51
	{
52 3
		$language = $this->_registry->get('language');
53
54
		/* process direction */
55
56 3
		foreach ($this->_directionArray as $direction => $valueArray)
57
		{
58 3
			if (in_array($language, $valueArray))
59
			{
60 1
				return $direction;
61
			}
62
		}
63 2
		return $this->_direction;
64
	}
65
}
66