Completed
Push — master ( b69bd3...8db10c )
by Karsten
01:49
created

IsMultipleOf::__invoke()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 5
nc 2
nop 1
crap 4
1
<?php
2
/**
3
 * Created by gerk on 01.12.17 23:33
4
 */
5
6
namespace PeekAndPoke\Component\Psi\Psi\Num;
7
8
use PeekAndPoke\Component\Psi\Functions\ParameterizedUnaryFunction;
9
10
/**
11
 *
12
 *
13
 * @author Karsten J. Gerber <[email protected]>
14
 */
15
class IsMultipleOf extends ParameterizedUnaryFunction
16
{
17
    /**
18
     * @param mixed $input
19
     *
20
     * @return bool
21
     */
22 100
    public function __invoke($input)
23
    {
24 100
        $factor = $this->getValue();
25
26 100
        if (! is_numeric($factor) || ! is_numeric($input) || (float) $factor === 0.0) {
27 12
            return false;
28
        }
29
30 88
        return ($input % $factor) === 0;
31
    }
32
}
33