IsIntegerString::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10
cc 3
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\UnaryFunction;
11
12
/**
13
 * IsIntegerString check if the given value is an integer encoded as a string
14
 *
15
 * @see    IsIntegerStringIsNotIntegerStringTest
16
 *
17
 * @author Karsten J. Gerber <[email protected]>
18
 */
19
class IsIntegerString implements UnaryFunction
20
{
21
    /**
22
     * @param mixed $input
23
     *
24
     * @return bool
25
     */
26 52
    public function __invoke($input)
27
    {
28
        /** @noinspection TypeUnsafeComparisonInspection */
29 52
        return is_string($input)
30 52
               && is_numeric($input)
31 52
               && (((int) $input) == $input) // the non-type-safe comparison here is on purpose
32
            ;
33
    }
34
}
35