PrimitiveField   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 52.38 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 22
loc 42
c 0
b 0
f 0
wmc 7
lcom 0
cbo 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handles() 9 9 1
B inflate() 13 13 5
A getDescription() 0 2 1

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 rtens\domin\delivery\cli\fields;
3
4
use rtens\domin\delivery\cli\CliField;
5
use rtens\domin\Parameter;
6
use watoki\reflect\type\DoubleType;
7
use watoki\reflect\type\FloatType;
8
use watoki\reflect\type\IntegerType;
9
use watoki\reflect\type\LongType;
10
use watoki\reflect\type\StringType;
11
12
class PrimitiveField implements CliField {
13
14
    /**
15
     * @param \rtens\domin\Parameter $parameter
16
     * @return bool
17
     */
18 View Code Duplication
    public function handles(Parameter $parameter) {
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...
19
        return in_array(get_class($parameter->getType()), [
20
            StringType::class,
21
            IntegerType::class,
22
            FloatType::class,
23
            LongType::class,
24
            DoubleType::class
25
        ]);
26
    }
27
28
    /**
29
     * @param Parameter $parameter
30
     * @param string $serialized
31
     * @return mixed
32
     */
33 View Code Duplication
    public function inflate(Parameter $parameter, $serialized) {
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...
34
        switch (get_class($parameter->getType())) {
35
            case LongType::class:
36
            case IntegerType::class:
37
                return (int)$serialized;
38
            case DoubleType::class:
39
                return (double)$serialized;
40
            case FloatType::class:
41
                return (float)$serialized;
42
            default:
43
                return (string)$serialized;
44
        }
45
    }
46
47
    /**
48
     * @param Parameter $parameter
49
     * @return string
50
     */
51
    public function getDescription(Parameter $parameter) {
52
    }
53
}