AbstractJsonConverter::processEmptyArrays()   A
last analyzed

Complexity

Conditions 5
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
rs 9.6111
c 0
b 0
f 0
cc 5
nc 1
nop 0
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