Completed
Branch develop (9e5d0f)
by Nate
01: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\ember\helpers;
10
11
use Craft;
12
use craft\web\Controller as CraftWebController;
13
use yii\web\Controller as WebController;
14
use yii\web\Response;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
class ArrayHelper extends \craft\helpers\ArrayHelper
21
{
22
    /**
23
     * Filters null values from an array.
24
     *
25
     * @param array $arr
26
     *
27
     * @return array
28
     */
29
    public static function filterNullValuesFromArray(array $arr): array
30
    {
31
        return array_filter($arr, function ($value): bool {
32
            return $value !== null;
33
        });
34
    }
35
36
    /**
37
     * Filters null values from an array.
38
     *
39
     * @param array $arr
40
     *
41
     * @return array
42
     */
43
    public static function filterEmptyAndNullValuesFromArray(array $arr): array
44
    {
45
        return array_filter($arr, function ($value): bool {
46
            return $value !== null && $value !== '';
47
        });
48
    }
49
}
50