ArgumentsFormatter::expandArgument()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 9.2
cc 4
eloc 6
nc 3
nop 2
crap 4
1
<?php
2
3
namespace EasyTaxi\NewRelic\Formatter;
4
5
class ArgumentsFormatter implements FormatterInterface
6
{
7 10
    public function format(array $arguments)
8
    {
9 10
        $output = new \ArrayObject();
10 10
        foreach ($arguments as $key => $value) {
11 5
            if (null === $value || is_scalar($value)) {
12 2
                $output[$key] = $value;
13
            } else {
14 4
                $this->expandArgument($value, $output);
15
            }
16
        }
17
18 10
        return $output;
19
    }
20
21 4
    private function expandArgument($argument, $flatten)
22
    {
23 4
        foreach ($argument as $key => $value) {
24 1
            if (null === $value || is_scalar($value)) {
25 1
                $flatten[$key] = $value;
26
            } else {
27 1
                $flatten[$key] = @json_encode($value);
28
            }
29
        }
30 4
    }
31
}
32