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

IsIntegerString   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
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