Completed
Push — master ( 1358d6...984c1e )
by Karsten
01:40
created

IsIntegerString::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 8
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 3
eloc 4
nc 3
nop 1
crap 3
1
<?php
2
/**
3
 * File was created 01.10.2015 18:02
4
 *
5
 * @author Karsten J. Gerber <[email protected]>
6
 */
7
8
namespace PeekAndPoke\Component\Psi\Psi;
9
10
use PeekAndPoke\Component\Psi\Functions\Unary\AbstractUnaryFunction;
11
12
/**
13
 * IsIntegerString check if the string contains an integer
14
 *
15
 * @author Karsten J. Gerber <[email protected]>
16
 */
17 View Code Duplication
class IsIntegerString extends AbstractUnaryFunction
18
{
19
    /**
20
     * @param mixed $input
21
     *
22
     * @return bool
23
     */
24 52
    public function __invoke($input)
25
    {
26
        /** @noinspection TypeUnsafeComparisonInspection */
27 52
        return is_string($input)
28 52
               && is_numeric($input)
29 52
               && (((int) $input) == $input) // the non-type-safe comparison here is on purpose
30
            ;
31
    }
32
}
33