RemoveEmptyInArrayTransformer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 16
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 3 1
A validate() 0 3 1
A removeEmptyInArray() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Darkilliant\ImportBundle\Transformer;
6
7
class RemoveEmptyInArrayTransformer extends AbstractTransformer
8
{
9 1
    public function transform($value, string $name = '', array $options = [])
10
    {
11 1
        return $this->removeEmptyInArray($value);
12
    }
13
14 1
    public function validate($value, string $name = '', array $options = []): bool
15
    {
16 1
        return true;
17
    }
18
19
    private function removeEmptyInArray($value)
20
    {
21 1
        return array_filter($value, function ($item) {
22 1
            return !empty((is_array($item)) ? $this->removeEmptyInArray($item) : $item);
23 1
        });
24
    }
25
}
26