Completed
Push — master ( 366fbf...5f1478 )
by Rafael
02:45
created

FloatParser   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

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
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Object\Parser;
11
12
class FloatParser implements ValueParserInterface
13
{
14
    const NAME = 'float';
15
16
    /**
17
     * @inheritDoc
18
     */
19
    public function getName()
20
    {
21
        return self::NAME;
22
    }
23
24
    /**
25
     * @inheritDoc
26
     */
27
    public function toObjectValue($value, $type, \ReflectionProperty $property, $object)
28
    {
29
        if ($type === 'float' || $type === 'double') {
30
            return (float)$value;
31
        }
32
33
        return $value;
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39
    public function toArrayValue($value, $type, \ReflectionProperty $property, $object)
40
    {
41
        return $value;
42
    }
43
}