Completed
Push — master ( ba350c...9968d0 )
by Korvin
05:03
created

helpers.php ➔ head()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Get an item from an array based on a key
5
 *
6
 * @param array $array
7
 * @param string $key
8
 * @param mixed $default
9
 * @return mixed
10
 */
11
function array_get(array $array, $key, $default = null) {
12
    if (isset($array[$key])) {
13
        return $array[$key];
14
    }
15
16
    return $default;
17
}
18
19
function head(array $array) {
20
    return reset($array);
21
}
22
23
function tail(array $array) {
24
    return end($array);
25
}
26