ArrayHelper::ensure()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 3
eloc 4
nc 2
nop 1
1
<?php
2
namespace phphound\helper;
3
4
/**
5
 * Array helper.
6
 */
7
class ArrayHelper
8
{
9
    /**
10
     * Ensure the value is an array. If it is not, return an empty array.
11
     * @param Mixed $value value to be verified.
12
     * @return array value itself or an empty array.
13
     */
14
    public static function ensure($value)
15
    {
16
        if (empty($value) || !is_array($value)) {
17
            return [];
18
        }
19
        return $value;
20
    }
21
}
22