IntHelper::parseInt()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 0
cts 4
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
namespace Katapoka\Ahgora;
3
4
abstract class IntHelper
5
{
6
    public static function parseInt($value)
7
    {
8
        if (!!preg_match('/\d+/', $value)) {
9
            return (int) $value;
10
        }
11
12
        return 0;
13
    }
14
15
    public static function parseNullableInt($value)
16
    {
17
        if ($value === null) {
18
            return null;
19
        }
20
21
        return self::parseInt($value);
22
    }
23
}
24