Completed
Push — master ( 91f892...09365e )
by Asmir
02:45
created

BaseTypesHandler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 54 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 5
c 2
b 1
f 1
lcom 0
cbo 2
dl 27
loc 50
ccs 0
cts 41
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 0 17 1
A simpleListOfToXml() 15 15 2
A simpleListOfFromXml() 12 12 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler;
3
4
use JMS\Serializer\Context;
5
use JMS\Serializer\GraphNavigator;
6
use JMS\Serializer\Handler\SubscribingHandlerInterface;
7
use JMS\Serializer\XmlDeserializationVisitor;
8
use JMS\Serializer\XmlSerializationVisitor;
9
10
class BaseTypesHandler implements SubscribingHandlerInterface
11
{
12
13
    public static function getSubscribingMethods()
14
    {
15
        return array(
16
            array(
17
                'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
18
                'format' => 'xml',
19
                'type' => 'GoetasWebservices\Xsd\XsdToPhp\Jms\SimpleListOf',
20
                'method' => 'simpleListOfToXml'
21
            ),
22
            array(
23
                'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
24
                'format' => 'xml',
25
                'type' => 'GoetasWebservices\Xsd\XsdToPhp\Jms\SimpleListOf',
26
                'method' => 'simpleListOfFromXML'
27
            )
28
        );
29
    }
30
31 View Code Duplication
    public function simpleListOfToXml(XmlSerializationVisitor $visitor, $object, array $type, Context $context)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
34
        $newType = array(
35
            'name' => $type["params"][0]["name"],
36
            'params' => array()
37
        );
38
39
        $ret = array();
40
        foreach ($object as $v) {
41
            $ret[] = $context->accept($v, $newType)->data;
42
        }
43
44
        return $visitor->getDocument()->createTextNode(implode(" ", $ret));
45
    }
46
47 View Code Duplication
    public function simpleListOfFromXml(XmlDeserializationVisitor $visitor, $node, array $type, Context $context)
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...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $newType = array(
50
            'name' => $type["params"][0]["name"],
51
            'params' => array()
52
        );
53
        $ret = array();
54
        foreach (explode(" ", (string)$node) as $v) {
55
            $ret[] = $context->accept($v, $newType);
56
        }
57
        return $ret;
58
    }
59
}
60
61