JsonSerialiser::serialise()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of Payload.
5
 *
6
 * (c) DraperStudio <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DraperStudio\Payload\Serialisers;
13
14
use DraperStudio\Payload\Contracts\Serialiser;
15
use Symfony\Component\Serializer\Encoder\JsonEncoder;
16
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
17
use Symfony\Component\Serializer\Serializer as SymfonySerialiser;
18
19
/**
20
 * Class JsonSerialiser.
21
 */
22
class JsonSerialiser implements Serialiser
23
{
24
    /**
25
     * @param $input
26
     *
27
     * @return mixed
28
     */
29 6
    public function serialise($input)
30
    {
31 6
        return (new SymfonySerialiser(
32 6
            [new ObjectNormalizer()], [new JsonEncoder()]
33 6
        ))->serialize($input, 'json');
34
    }
35
}
36