Completed
Push — master ( 11971b...eeafb3 )
by Nate
01:16
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
     * @return array
22
     */
23
    public static function filterNullValuesFromArray(array $arr): array
24
    {
25
        return array_filter($arr, function ($value): bool {
26
            return $value !== null;
27
        });
28
    }
29
30
    /**
31
     * Filters null values from an array.
32
     *
33
     * @param array $arr
34
     * @return array
35
     */
36
    public static function filterEmptyAndNullValuesFromArray(array $arr): array
37
    {
38
        return array_filter($arr, function ($value): bool {
39
            return $value !== null && $value !== '';
40
        });
41
    }
42
}
43