Completed
Push — develop ( 85588e...ca6c48 )
by Daniel
28s queued 11s
created

cfg_utils::get_selected_option()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 *
5
 * @package sitemaker
6
 * @copyright (c) 2019 Daniel A. (blitze)
7
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
 *
9
 */
10
11
namespace blitze\sitemaker\services\blocks\config;
12
13
class cfg_utils
14
{
15
	/**
16
	 * Force array
17
	 *
18
	 * @param mixed $items
19
	 * @return array
20
	 */
21
	public static function ensure_array($items)
22
	{
23
		return is_array($items) ? $items : explode(',', $items);
24
	}
25
26
	/**
27
	 * Force multi dimensional array
28
	 *
29
	 * @param mixed $options
30
	 * @param string $css_class
31
	 * @return array
32
	 */
33
	public static function ensure_multi_array($options, &$css_class)
34
	{
35
		$test = current(cfg_utils::ensure_array($options));
36
		if (!is_array($test))
37
		{
38
			$css_class = '';
39
			$options = array($options);
40
		}
41
42
		return array_map('array_filter', $options);
43
	}
44
}
45