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

FloatValidator::getMessages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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
}