Completed
Push — master ( 79d774...fe5ef4 )
by Derek Stephen
03:18
created

FloatValidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 24
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 7 2
A getMessages() 0 4 1
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 26/12/2016
5
 * Time: 14:59
6
 */
7
8
namespace Del\Form\Validator;
9
10
use Exception;
11
12
class FloatValidator implements ValidatorInterface
13
{
14
    /**
15
     * @param  mixed $value
16
     * @return bool
17
     * @throws Exception If validation of $value is impossible
18
     */
19 1
    public function isValid($value)
20
    {
21 1
        if (!is_numeric($value)) {
22 1
            return false;
23
        }
24 1
        return is_float((float) $value);
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function getMessages()
31
    {
32
        return ['Value is not a float.'];
33
    }
34
35
}