Completed
Push — master ( 4066ce...b4c895 )
by Sebastian
03:10
created

AbstractNumber::sanitize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Linna Filter
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2018, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types = 1);
11
12
namespace Linna\Filter\Rules;
13
14
/**
15
 * Abstract Number
16
 */
17
class AbstractNumber
18
{
19
    /**
20
     * Sanitize.
21
     *
22
     * @param mixed $value
23
     */
24 49
    public function sanitize(&$value): void
25
    {
26 49
        if (fmod((float) $value, 1.0) === 0.0) {
27 44
            settype($value, 'integer');
28 44
            return;
29
        }
30
31 5
        settype($value, 'float');
32 5
    }
33
}
34