Passed
Push — master ( 898e5e...70a169 )
by Christopher
03:30
created

IsOK::isNotNullIstanceOf()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
nc 3
cc 3
eloc 6
nop 2
1
<?php
2
namespace AlgoWeb\ODataMetadata;
3
4
abstract class IsOK
5
{
6
    abstract protected function IsOK(&$msg);
7
8
    protected function isStringNotNullOrEmpty($str){
9
        if($this->isStringNull($str)){
0 ignored issues
show
Bug introduced by
The method isStringNull() does not seem to exist on object<AlgoWeb\ODataMetadata\IsOK>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
10
            return false;
11
        }
12
        if(empty(trim($str))){
13
           return false;
14
        }
15
        return true;
16
    }
17
18
    protected function isStringNotNull($str)
19
    {
20
        if(null == $str){
21
           return false;
22
        }
23
        if(!is_string($str)){
24
           return false;
25
        }
26
        return true;
27
    }
28
29
    protected  function isNotNullIstanceOf($var, $insanceOf){
30
        if(null == $var){
31
            return false;
32
        }
33
        if(!($var instanceof $insanceOf)){
34
            return false;
35
        }
36
        return true;
37
    }
38
39
    protected function isValidArray($arr, $insanceOf, $minCount = -1, $maxCount = -1){
40
        if(null == $arr){
41
            return false;
42
        }
43
        if(!is_array ($arr)){
44
            return false;
45
        }
46
        if($minCount != -1 && count($arr) < $minCount){
47
            return false;
48
        }
49
        if($maxCount != -1 && count($arr) > $maxCount){
50
            return false;
51
        }
52
        foreach($arr as $item){
53
            if(!($item instanceof $insanceOf)){
54
                return false;
55
            }
56
        }
57
        return true;
58
    }
59
}
60