AbstractJsonConverter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 6
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A processEmptyArrays() 0 9 5
1
<?php
2
3
namespace MLD\Converter;
4
5
/**
6
 * Class AbstractJsonConverter
7
 */
8
abstract class AbstractJsonConverter extends AbstractConverter
9
{
10
11
    /**
12
     * Special case for empty arrays that should be encoded as empty JSON objects
13
     */
14
    protected function processEmptyArrays()
15
    {
16
        array_walk($this->countries, function (&$country) {
17
            if (isset($country['languages']) && empty($country['languages'])) {
18
                $country['languages'] = new \stdClass();
19
            }
20
21
            if (isset($country['name']['native']) && empty($country['name']['native'])) {
22
                $country['name']['native'] = new \stdClass();
23
            }
24
        });
25
    }
26
}
27