ArgumentsFormatter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 27
c 0
b 0
f 0
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A format() 0 13 4
A expandArgument() 0 10 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