Completed
Push — master ( e3199e...dd66f1 )
by Nate
08:31 queued 06:54
created

ArrayHelper::insertSequential()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 40
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
dl 0
loc 40
ccs 0
cts 26
cp 0
rs 8.439
c 0
b 0
f 0
cc 5
eloc 19
nc 6
nop 3
crap 30
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-ember/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-ember
7
 */
8
9
namespace flipbox\ember\helpers;
10
11
/**
12
 * @author Flipbox Factory <[email protected]>
13
 * @since 1.0.0
14
 */
15
class ArrayHelper extends \craft\helpers\ArrayHelper
16
{
17
    /**
18
     * Filters null values from an array.
19
     *
20
     * @param array $arr
21
     *
22
     * @return array
23
     */
24
    public static function filterNullValuesFromArray(array $arr): array
25
    {
26
        return array_filter($arr, function ($value): bool {
27
            return $value !== null;
28
        });
29
    }
30
31
    /**
32
     * Filters null values from an array.
33
     *
34
     * @param array $arr
35
     *
36
     * @return array
37
     */
38
    public static function filterEmptyAndNullValuesFromArray(array $arr): array
39
    {
40
        return array_filter($arr, function ($value): bool {
41
            return $value !== null && $value !== '';
42
        });
43
    }
44
}
45