ArgumentsFormatter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A format() 0 13 4
A expandArgument() 0 10 4
1
<?php
2
3
namespace DJStarCOM\NewRelic\Formatter;
4
5
class ArgumentsFormatter implements FormatterInterface
6
{
7
    /**
8
     * @param array $arguments
9
     * @return \ArrayObject
10
     */
11 11
    public function format(array $arguments)
12
    {
13 11
        $output = new \ArrayObject();
14 11
        foreach ($arguments as $key => $value) {
15 5
            if (null === $value || is_scalar($value)) {
16 2
                $output[$key] = $value;
17
            } else {
18 5
                $this->expandArgument($value, $output);
19
            }
20
        }
21
22 11
        return $output;
23
    }
24
25 4
    private function expandArgument($argument, &$flatten)
26
    {
27 4
        foreach ($argument as $key => $value) {
28 1
            if (null === $value || is_scalar($value)) {
29 1
                $flatten[$key] = $value;
30
            } else {
31 1
                $flatten[$key] = @json_encode($value);
32
            }
33
        }
34 4
    }
35
}
36