Passed
Branch develop (5fc816)
by JAIME ELMER
01:58
created

Validations::isIn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace F72X\Tools;
4
5
class Validations {
6
7
    /**
8
     * Checks if the provided value is a DNI.
9
     * @param string $value
10
     * @return boolean
11
     */
12
    public static function isDni($value) {
13
        return is_numeric($value) && (strlen($value) == 8);
14
    }
15
16
    /**
17
     * Checks if the provided value is a RUC.
18
     * @param string $value
19
     * @return boolean
20
     */
21
    public static function isRuc($value) {
22
        return is_numeric($value) && (strlen($value) == 11);
23
    }
24
25
    /**
26
     * Checks if a value exist in an array.
27
     * @param mixed $needle The searched value.
28
     * @param array $haystack The array.
29
     * @param boolean $strict
30
     * If the third parameter *strict* is set to **false**
31
     * then the **isIn** function wont check the
32
     * *needle* in the *haystack*.
33
     * types of the
34
35
     * @return type
0 ignored issues
show
Bug introduced by
The type F72X\Tools\type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
36
     */
37
    public static function isIn($needle, array $haystack, $strict = true) {
38
        return in_array($needle, $haystack, $strict);
0 ignored issues
show
Bug Best Practice introduced by
The expression return in_array($needle, $haystack, $strict) returns the type boolean which is incompatible with the documented return type F72X\Tools\type.
Loading history...
39
    }
40
41
    public static function isArray($var) {
42
        return is_array($var);
43
    }
44
45
}
46