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

IsNumericString   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 1
dl 16
loc 16
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 8 8 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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