Types   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 76
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A callable() 0 3 1
A numeric() 0 3 1
A array() 0 3 1
A object() 0 3 1
A boolean() 0 3 1
A int() 0 3 1
A string() 0 3 1
A float() 0 3 1
A instanceof() 0 5 1
1
<?php
2
/**
3
 * Copyright 2017 NanoSector
4
 *
5
 * You should have received a copy of the MIT license with the project.
6
 * See the LICENSE file for more information.
7
 */
8
9
namespace ValidationClosures;
10
11
use Closure;
12
13
class Types
14
{
15
	/**
16
	 * @return Closure
17
	 */
18 18
	public static function string(): Closure
19
	{
20 18
		return Utils::createClosureFromCallable('is_string');
21
	}
22
23
	/**
24
	 * @return Closure
25
	 */
26 12
	public static function int(): Closure
27
	{
28 12
		return Utils::createClosureFromCallable('is_int');
29
	}
30
31
	/**
32
	 * @return Closure
33
	 */
34 6
	public static function float(): Closure
35
	{
36 6
		return Utils::createClosureFromCallable('is_float');
37
	}
38
39
	/**
40
	 * @return Closure
41
	 */
42 2
	public static function boolean(): Closure
43
	{
44 2
		return Utils::createClosureFromCallable('is_bool');
45
	}
46
47
	/**
48
	 * @return Closure
49
	 */
50 2
	public static function array(): Closure
51
	{
52 2
		return Utils::createClosureFromCallable('is_array');
53
	}
54
55
	/**
56
	 * @return Closure
57
	 */
58 2
	public static function callable(): Closure
59
	{
60 2
		return Utils::createClosureFromCallable('is_callable');
61
	}
62
63
	/**
64
	 * @return Closure
65
	 */
66 2
	public static function object(): Closure
67
	{
68 2
		return Utils::createClosureFromCallable('is_object');
69
	}
70
71
    /**
72
     * @return Closure
73
     */
74 2
    public static function numeric(): Closure
75
    {
76 2
        return Utils::createClosureFromCallable('is_numeric');
77
	}
78
79
	/**
80
	 * @param string $class
81
	 *
82
	 * @return Closure
83
	 */
84
	public static function instanceof(string $class): Closure
85
	{
86 2
		return static function ($value) use ($class)
87
		{
88 2
			return $value instanceof $class;
89 2
		};
90
	}
91
}