Completed
Push — feature/other-validation ( 582c96...3c7e86 )
by Narcotic
109:38 queued 43:32
created

SchemaTypeHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A serializeSchemaTypeToJson() 0 14 2
1
<?php
2
/**
3
 * SchemaTypeHandler class file
4
 */
5
6
namespace Graviton\SchemaBundle\Serializer\Handler;
7
8
use Graviton\SchemaBundle\Document\SchemaType;
9
use JMS\Serializer\Context;
10
use JMS\Serializer\JsonSerializationVisitor;
11
12
/**
13
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
14
 * @license  http://opensource.org/licenses/GPL GPL
15
 * @link     http://swisscom.ch
16
 */
17
class SchemaTypeHandler
18
{
19
20
    /**
21
     * Serialize SchemaType to JSON
22
     *
23
     * @param JsonSerializationVisitor $visitor    Visitor
24
     * @param SchemaType               $schemaType type
25
     * @param array                    $type       Type
26
     * @param Context                  $context    Context
27
     *
28
     * @return array
29
     */
30
    public function serializeSchemaTypeToJson(
31
        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...
32
        SchemaType $schemaType,
33
        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...
34
        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...
35
    ) {
36
        $types = $schemaType->getTypes();
37
38
        if (count($types) === 1) {
39
            return array_pop($types);
40
        }
41
42
        return $types;
43
    }
44
}
45