Passed
Push — master ( 42367a...08368b )
by Sebastian
02:40
created

Request_Param_Validator_Integer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 14
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultOptions() 0 3 1
A _validate() 0 7 2
1
<?php
2
/**
3
 * File containing the {@link Request_Param_Validator_Integer} class.
4
 *
5
 * @package Application Utils
6
 * @subpackage Request
7
 * @see Request_Param_Validator_Integer
8
 */
9
10
declare(strict_types=1);
11
12
namespace AppUtils;
13
14
/**
15
 * Validates an integer.
16
 * 
17
 * Note: returns null if the value is not an integer, since any other 
18
 * value would be a valid integer that may have meaning in the application.
19
 *
20
 * @package Application Utils
21
 * @subpackage Request
22
 * @author Sebastian Mordziol <[email protected]>
23
 */
24
class Request_Param_Validator_Integer extends Request_Param_Validator
25
{
26
    public function getDefaultOptions() : array
27
    {
28
        return array();
29
    }
30
    
31
    protected function _validate()
32
    {
33
        if(ConvertHelper::isInteger($this->value)) {
34
            return intval($this->value);
35
        }
36
        
37
        return null;
38
    }
39
}
40