Passed
Push — master ( bed608...307714 )
by SignpostMarv
06:30
created

NestedTypeParanoia   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A MaybeFoundInArray() 0 5 2
A ForceInt() 0 3 2
A NotYetAppendedToTree() 0 7 3
1
<?php
2
/**
3
* Base daft objects.
4
*
5
* @author SignpostMarv
6
*/
7
declare(strict_types=1);
8
9
namespace SignpostMarv\DaftObject;
10
11
class NestedTypeParanoia
12
{
13
    /**
14
    * @param mixed $needle
15
    */
16 60
    public static function MaybeFoundInArray($needle, array $haystack) : ? int
17
    {
18 60
        $out = array_search($needle, $haystack, true);
19
20 60
        return is_int($out) ? $out : null;
21
    }
22
23
    /**
24
    * @param mixed $maybe
25
    */
26 96
    public static function ForceInt($maybe) : int
27
    {
28 96
        return is_int($maybe) ? $maybe : (int) $maybe;
29
    }
30
31 88
    public static function NotYetAppendedToTree(DaftNestedObject $object) : bool
32
    {
33 88
        $left = $object->GetIntNestedLeft();
34 88
        $right = $object->GetIntNestedRight();
35 88
        $level = $object->GetIntNestedLevel();
36
37 88
        return 0 === $left && 0 === $right && 0 === $level;
38
    }
39
}
40