Passed
Push — master ( 7aff0e...898e5e )
by Christopher
05:50 queued 02:04
created

IsOK.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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)){
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
        if(!is_string($str)){
23
           return false;
24
        }
25
        return true;
26
    }
27
28
    protected  function isNotNullIstanceOf($var, $insanceOf){
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_PROTECTED
Loading history...
29
        if(null == $var){
30
            return false;
31
        }
32
        if(!($var instanceof $insanceOf)){
33
            return false;
34
        }
35
        return true;
36
    }
37
38
    protected function isValidArray($arr, $insanceOf, $minCount = -1, $maxCount = -1){
39
        if(null == $arr){
40
            return false;
41
        }
42
        if(!is_array ($arr)){
43
            return false;
44
        }
45
        if($minCount != -1 && count($arr) < $minCount){
46
            return false;
47
        }
48
        if($maxCount != -1 && count($arr) > $maxCount){
49
            return false;
50
        }
51
        foreach($arr as $item){
52
            if(!($item instanceof $insanceOf)){
53
                return false;
54
            }
55
        }
56
        return true;
57
    }
58
}
59