Passed
Push — master ( 961468...052950 )
by Theo
01:43
created

Serializer::serialize()   A

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