NDJson::convert()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 1
rs 10
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Helper;
4
5
final class NDJson
6
{
7
    /**
8
     * @return string
9
     */
10 1
    public static function contentType()
11
    {
12 1
        return 'application/x-ndjson';
13
    }
14
15
    /**
16
     * @param array $events
17
     * @return string
18
     */
19 1
    public static function convert(array $events)
20
    {
21 1
        return array_reduce(
22 1
            $events,
23 1
            static function ($carry, $item) {
24 1
                $carry .= json_encode($item) . PHP_EOL;
25
26 1
                return $carry;
27
            }
28 1
        );
29
    }
30
}
31