Passed
Push — master ( 12f2fc...cdaa8b )
by Rick
01:45
created

Types::numeric()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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
class Types
12
{
13
	/**
14
	 * @return \Closure
15
	 */
16 9
	public static function string(): \Closure
17
	{
18 9
		return \Closure::fromCallable('is_string');
19
	}
20
21
	/**
22
	 * @return \Closure
23
	 */
24 6
	public static function int(): \Closure
25
	{
26 6
		return \Closure::fromCallable('is_int');
27
	}
28
29
	/**
30
	 * @return \Closure
31
	 */
32 3
	public static function float(): \Closure
33
	{
34 3
		return \Closure::fromCallable('is_float');
35
	}
36
37
	/**
38
	 * @return \Closure
39
	 */
40 1
	public static function boolean(): \Closure
41
	{
42 1
		return \Closure::fromCallable('is_bool');
43
	}
44
45
	/**
46
	 * @return \Closure
47
	 */
48
	public static function array(): \Closure
49
	{
50 1
		return \Closure::fromCallable('is_array');
51
	}
52
53
	/**
54
	 * @return \Closure
55
	 */
56
	public static function callable(): \Closure
57
	{
58 1
		return \Closure::fromCallable('is_callable');
59
	}
60
61
	/**
62
	 * @return \Closure
63
	 */
64 1
	public static function object(): \Closure
65
	{
66 1
		return \Closure::fromCallable('is_object');
67
	}
68
69
    /**
70
     * @return \Closure
71
     */
72 1
    public static function numeric(): \Closure
73
    {
74 1
        return \Closure::fromCallable('is_numeric');
75
	}
76
77
	/**
78
	 * @param string $class
79
	 *
80
	 * @return \Closure
81
	 */
82
	public static function instanceof(string $class): \Closure
83
	{
84
		return function ($value) use ($class)
85
		{
86
			return $value instanceof $class;
87
		};
88
	}
89
}