FloatParser   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A toObjectValue() 0 8 3
A toArrayValue() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the rafrsr/lib-array2object package.
5
 *
6
 * (c) Rafael SR <https://github.com/rafrsr>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Rafrsr\LibArray2Object\Parser;
12
13
class FloatParser implements ValueParserInterface
14
{
15
    const NAME = 'float';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function getName()
21
    {
22
        return self::NAME;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function toObjectValue($value, $type, \ReflectionProperty $property, $object)
29
    {
30
        if ($type === 'float' || $type === 'double') {
31
            return (float) $value;
32
        }
33
34
        return $value;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function toArrayValue($value, $type, \ReflectionProperty $property, $object)
41
    {
42
        return $value;
43
    }
44
}
45