Completed
Push — master ( c783ca...a18c65 )
by WEBEWEB
06:08
created

ArrayUtility::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 3
1
<?php
2
3
/**
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2017 NdC/WBW
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\Utility;
13
14
/**
15
 * Array utility.
16
 *
17
 * @author NdC/WBW <https://github.com/webeweb/>
18
 * @package WBW\Library\Core\Utility
19
 * @final
20
 */
21
final class ArrayUtility {
22
23
	/**
24
	 * Get a value.
25
	 *
26
	 * @param array $array The array.
27
	 * @param mixed $key The key.
28
	 * @param mixed $default The default value.
29
	 * @return mixed Returns the value in case of success, $default otherwise.
30
	 */
31
	public static function get(array $array, $key, $default = null) {
32
		return true === array_key_exists($key, $array) ? $array[$key] : $default;
33
	}
34
35
}
36