Test Failed
Push — master ( 3c6fc5...755ce0 )
by Rick
02:12
created

Types::boolean()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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