Passed
Push — master ( b7b0fb...908416 )
by Christopher
03:27
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
    {
10
        if ($this->isStringNull($str)) {
0 ignored issues
show
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...
11
            return false;
12
        }
13
        if (empty(trim($str))) {
14
            return false;
15
        }
16
        return true;
17
    }
18
19
    protected function isStringNotNull($str)
20
    {
21
        if (null == $str) {
22
            return false;
23
        }
24
        if (!is_string($str)) {
25
            return false;
26
        }
27
        return true;
28
    }
29
30
    protected function isNotNullIstanceOf($var, $insanceOf)
31
    {
32
        if (null == $var) {
33
            return false;
34
        }
35
        if (!($var instanceof $insanceOf)) {
36
            return false;
37
        }
38
        return true;
39
    }
40
41
    protected function isValidArray($arr, $insanceOf, $minCount = -1, $maxCount = -1)
42
    {
43
        if (null == $arr) {
44
            return false;
45
        }
46
        if (!is_array($arr)) {
47
            return false;
48
        }
49
        if ($minCount != -1 && count($arr) < $minCount) {
50
            return false;
51
        }
52
        if ($maxCount != -1 && count($arr) > $maxCount) {
53
            return false;
54
        }
55
        foreach ($arr as $item) {
56
            if (!($item instanceof $insanceOf)) {
57
                return false;
58
            }
59
        }
60
        return true;
61
    }
62
}
63