Test Failed
Push — master ( 1f5d45...b072a0 )
by JAIME ELMER
04:15
created

Validations::isRuc()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MÓDULO DE EMISIÓN ELECTRÓNICA F72X
5
 * UBL 2.1
6
 * Version 1.1
7
 * 
8
 * Copyright 2018, Jaime Cruz
9
 */
10
11
namespace F72X\Tools;
12
13
class Validations {
14
15
    /**
16
     * Checks if the provided value is a DNI.
17
     * @param string $value
18
     * @return boolean
19
     */
20
    public static function isDni($value) {
21
        return is_numeric($value) && (strlen($value) == 8);
22
    }
23
24
    /**
25
     * Checks if the provided value is a RUC.
26
     * @param string $value
27
     * @return boolean
28
     */
29
    public static function isRuc($value) {
30
        return is_numeric($value) && (strlen($value) == 11);
31
    }
32
33
    /**
34
     * Checks if a value exist in an array.
35
     * @param mixed $needle The searched value.
36
     * @param array $haystack The array.
37
     * @param boolean $strict
38
     * If the third parameter *strict* is set to **false**
39
     * then the **isIn** function wont check the
40
     * *needle* in the *haystack*.
41
     * @return boolean
42
     */
43
    public static function isIn($needle, array $haystack, $strict = true) {
44
        return in_array($needle, $haystack, $strict);
45
    }
46
47
    public static function isArray($var) {
48
        return is_array($var);
49
    }
50
51
}
52