Completed
Push — develop ( 11971b...45f15f )
by Nate
06:59
created

ArrayHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 30
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A filterNullValuesFromArray() 0 6 1
A filterEmptyAndNullValuesFromArray() 0 6 2
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\craft\ember\helpers;
10
11
/**
12
 * @author Flipbox Factory <[email protected]>
13
 * @since 2.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