Completed
Push — feature/fix-somescrutinizer-is... ( 03fa6a...7ccc0d )
by Narcotic
09:35
created

HashHandler::serializeHashToJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4286
cc 1
eloc 6
nc 1
nop 4
crap 2
1
<?php
2
/**
3
 * HashHandler class file
4
 */
5
6
namespace Graviton\DocumentBundle\Serializer\Handler;
7
8
use JMS\Serializer\Context;
9
use JMS\Serializer\JsonDeserializationVisitor;
10
use JMS\Serializer\JsonSerializationVisitor;
11
use Graviton\DocumentBundle\Entity\Hash;
12
13
/**
14
 * Hash handler for JMS serializer
15
 *
16
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
17
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
18
 * @link     http://swisscom.ch
19
 */
20
class HashHandler
21
{
22
    /**
23
     * Serialize Hash object
24
     *
25
     * @param JsonSerializationVisitor $visitor Visitor
26
     * @param Hash                     $data    Data
27
     * @param array                    $type    Type
28
     * @param Context                  $context Context
29
     * @return array
30
     */
31
    public function serializeHashToJson(
32
        JsonSerializationVisitor $visitor,
0 ignored issues
show
Unused Code introduced by
The parameter $visitor is not used and could be removed.

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

Loading history...
33
        Hash $data,
34
        array $type,
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed.

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

Loading history...
35
        Context $context
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

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

Loading history...
36
    ) {
37
        return $data;
38
    }
39
40
    /**
41
     * Deserialize Hash object
42
     *
43
     * @param JsonDeserializationVisitor $visitor Visitor
44
     * @param array                      $data    Data
45
     * @param array                      $type    Type
46
     * @param Context                    $context Context
47
     * @return Hash
48
     */
49
    public function deserializeHashFromJson(
50
        JsonDeserializationVisitor $visitor,
51
        array $data,
52
        array $type,
53
        Context $context
54
    ) {
55
        return new Hash($visitor->visitArray($data, $type, $context));
56
    }
57
}
58