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

IsNumericString::__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
namespace PeekAndPoke\Component\Psi\Psi;
8
9
use PeekAndPoke\Component\Psi\Functions\Unary\AbstractUnaryFunction;
10
11
/**
12
 * IsNumericString check if the string contains an number
13
 *
14
 * @author Karsten J. Gerber <[email protected]>
15
 */
16 View Code Duplication
class IsNumericString extends AbstractUnaryFunction
17
{
18
    /**
19
     * @param mixed $input
20
     *
21
     * @return bool
22
     */
23 56
    public function __invoke($input)
24
    {
25
        /** @noinspection TypeUnsafeComparisonInspection */
26 56
        return is_string($input)
27 56
               && is_numeric($input)
28 56
               && (((double) $input) == $input) // the non-type-safe comparison here is on purpose
29
            ;
30
    }
31
}
32