Serializer::serialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CalendarBundle\Serializer;
6
7
use CalendarBundle\Entity\Event;
8
9
class Serializer implements SerializerInterface
10
{
11
    /**
12
     * @param Event[] $events
13
     *
14
     * @return string json
15
     */
16 2
    public function serialize(array $events): string
17
    {
18 2
        $result = [];
19
20 2
        foreach ($events as $event) {
21 1
            $result[] = $event->toArray();
22
        }
23
24 2
        return json_encode($result);
25
    }
26
}
27