Passed
Pull Request — master (#28)
by Patrick
03:01
created

SerializerFacade::deserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of forecast.it.fill project.
7
 * (c) Patrick Jaja <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace ForecastAutomation\Serializer;
13
14
use ForecastAutomation\Kernel\AbstractFacade;
15
use ForecastAutomation\Serializer\Shared\Config\SerializerConstants;
16
17
/**
18
 * @method \ForecastAutomation\Serializer\SerializerFactory getFactory()
19
 */
20
class SerializerFacade extends AbstractFacade
21
{
22
    //ToDo: Support original feature scope ie. normalize attributes path
23
    // see here https://symfony.com/doc/current/components/serializer.html
24
    // https://jmsyst.com/libs/serializer
25
    public function serialize(object|array $dto, string $format = SerializerConstants::FORMAT_JSON): string
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

25
    public function serialize(object|array $dto, /** @scrutinizer ignore-unused */ string $format = SerializerConstants::FORMAT_JSON): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
        return \json_encode((array) $dto, JSON_THROW_ON_ERROR);
28
//        return $this->getFactory()->createSerializer()->serialize($dto, $format);
29
    }
30
31
    public function deserialize(
32
        string $serializedData,
33
//        string $dtoClassPath,
34
        string $format = SerializerConstants::FORMAT_JSON
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

34
        /** @scrutinizer ignore-unused */ string $format = SerializerConstants::FORMAT_JSON

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    ): array {
36
        return \json_decode($serializedData, true, 512, JSON_THROW_ON_ERROR);
37
//        return $this->getFactory()->createSerializer()->deserialize($serializedData, $dtoClassPath, $format);
38
    }
39
}
40