Completed
Push — master ( 929034...adc5e6 )
by Marcus
02:23
created

AbstractIntegerCase   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 38
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isInteger() 0 4 1
A isNumeric() 0 4 2
A isIntOrNumeric() 0 4 2
1
<?php
2
3
namespace Mbright\Validation\Rule\Validate;
4
5
class AbstractIntegerCase
6
{
7
    /**
8
     * Indicates if the given value is an integer.
9
     *
10
     * @param $value
11
     *
12
     * @return bool
13
     */
14 198
    protected function isInteger($value): bool
15
    {
16 198
        return is_int($value);
17
    }
18
19
    /**
20
     * Indicates if the given value is numeric.
21
     *
22
     * @param $value
23
     *
24
     * @return bool
25
     */
26 54
    protected function isNumeric($value): bool
27
    {
28 54
        return is_numeric($value) && $value == (int) $value;
29
    }
30
31
    /**
32
     * Indicates if the given value is an integer or numeric.
33
     *
34
     * @param $value
35
     *
36
     * @return bool
37
     */
38 33
    protected function isIntOrNumeric($value): bool
39
    {
40 33
        return $this->isInteger($value) || $this->isNumeric($value);
41
    }
42
}
43