PrimitiveField::inflate()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 13
Code Lines 11

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
c 0
b 0
f 0
rs 8.8571
cc 5
eloc 11
nc 5
nop 2
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
}