Passed
Push — master ( 442b95...b71bb5 )
by Rick
05:36
created
src/Ranges.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@  discard block
 block discarded – undo
11 11
 
12 12
 class Ranges
13 13
 {
14
-	/**
15
-	 * @param int $minimumLength
16
-	 * @param int $maximumLength
17
-	 *
18
-	 * @return \Closure
19
-	 */
20
-	public static function stringWithLengthBetween(int $minimumLength, int $maximumLength): \Closure
21
-	{
22
-		if ($maximumLength < 0 || $maximumLength < 1)
23
-			throw new \InvalidArgumentException('Minimum length cannot be below 0, maximum length cannot be below 1');
14
+    /**
15
+     * @param int $minimumLength
16
+     * @param int $maximumLength
17
+     *
18
+     * @return \Closure
19
+     */
20
+    public static function stringWithLengthBetween(int $minimumLength, int $maximumLength): \Closure
21
+    {
22
+        if ($maximumLength < 0 || $maximumLength < 1)
23
+            throw new \InvalidArgumentException('Minimum length cannot be below 0, maximum length cannot be below 1');
24 24
 
25
-		return function ($value) use ($minimumLength, $maximumLength)
26
-		{
27
-			return Types::string()($value) && static::intBetween($minimumLength, $maximumLength)(strlen($value));
28
-		};
29
-	}
25
+        return function ($value) use ($minimumLength, $maximumLength)
26
+        {
27
+            return Types::string()($value) && static::intBetween($minimumLength, $maximumLength)(strlen($value));
28
+        };
29
+    }
30 30
 
31
-	/**
32
-	 * @param int $minimum
33
-	 * @param int $maximum
34
-	 *
35
-	 * @return \Closure
36
-	 */
37
-	public static function intBetween(int $minimum, int $maximum): \Closure
38
-	{
31
+    /**
32
+     * @param int $minimum
33
+     * @param int $maximum
34
+     *
35
+     * @return \Closure
36
+     */
37
+    public static function intBetween(int $minimum, int $maximum): \Closure
38
+    {
39 39
         if ($maximum <= $minimum)
40 40
             throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
41 41
         
42
-		return function ($value) use ($minimum, $maximum)
43
-		{
44
-			return Types::int()($value) && ($value >= $minimum && $value <= $maximum);
45
-		};
46
-	}
42
+        return function ($value) use ($minimum, $maximum)
43
+        {
44
+            return Types::int()($value) && ($value >= $minimum && $value <= $maximum);
45
+        };
46
+    }
47 47
 
48 48
     /**
49 49
      * @param int $minimum
@@ -60,24 +60,24 @@  discard block
 block discarded – undo
60 60
         {
61 61
             return Types::int()($value) && ($value > $minimum && $value < $maximum);
62 62
         };
63
-	}
63
+    }
64 64
 
65
-	/**
66
-	 * @param float $minimum
67
-	 * @param float $maximum
68
-	 *
69
-	 * @return \Closure
70
-	 */
71
-	public static function floatBetween(float $minimum, float $maximum): \Closure
72
-	{
65
+    /**
66
+     * @param float $minimum
67
+     * @param float $maximum
68
+     *
69
+     * @return \Closure
70
+     */
71
+    public static function floatBetween(float $minimum, float $maximum): \Closure
72
+    {
73 73
         if ($maximum <= $minimum)
74 74
             throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
75 75
         
76
-		return function ($value) use ($minimum, $maximum)
77
-		{
78
-			return Types::float()($value) && ($value >= $minimum && $value <= $maximum);
79
-		};
80
-	}
76
+        return function ($value) use ($minimum, $maximum)
77
+        {
78
+            return Types::float()($value) && ($value >= $minimum && $value <= $maximum);
79
+        };
80
+    }
81 81
 
82 82
     /**
83 83
      * @param float $minimum
@@ -94,47 +94,47 @@  discard block
 block discarded – undo
94 94
         {
95 95
             return Types::float()($value) && ($value > $minimum && $value < $maximum);
96 96
         };
97
-	}
97
+    }
98 98
 
99
-	/**
100
-	 * @param array ...$allowedValues
101
-	 *
102
-	 * @return \Closure
103
-	 */
104
-	public static function enum(...$allowedValues): \Closure
105
-	{
106
-		return function ($value) use ($allowedValues)
107
-		{
108
-			return in_array($value, $allowedValues, true);
109
-		};
110
-	}
99
+    /**
100
+     * @param array ...$allowedValues
101
+     *
102
+     * @return \Closure
103
+     */
104
+    public static function enum(...$allowedValues): \Closure
105
+    {
106
+        return function ($value) use ($allowedValues)
107
+        {
108
+            return in_array($value, $allowedValues, true);
109
+        };
110
+    }
111 111
 
112
-	/**
113
-	 * @param array ...$allowedTypes
114
-	 *
115
-	 * @return \Closure
116
-	 */
117
-	public static function typeEnum(...$allowedTypes): \Closure
118
-	{
119
-		return function ($value) use ($allowedTypes)
120
-		{
121
-			return in_array(gettype($value), $allowedTypes, true);
122
-		};
123
-	}
112
+    /**
113
+     * @param array ...$allowedTypes
114
+     *
115
+     * @return \Closure
116
+     */
117
+    public static function typeEnum(...$allowedTypes): \Closure
118
+    {
119
+        return function ($value) use ($allowedTypes)
120
+        {
121
+            return in_array(gettype($value), $allowedTypes, true);
122
+        };
123
+    }
124 124
 
125
-	/**
126
-	 * @param array ...$allowedValues
127
-	 *
128
-	 * @return \Closure
129
-	 */
130
-	public static function stringOneOf(...$allowedValues): \Closure
131
-	{
132
-		if (!Utils::validateArray(Types::string(), $allowedValues))
133
-			throw new \InvalidArgumentException('Ranges::stringOneOf expects arguments of type string only');
125
+    /**
126
+     * @param array ...$allowedValues
127
+     *
128
+     * @return \Closure
129
+     */
130
+    public static function stringOneOf(...$allowedValues): \Closure
131
+    {
132
+        if (!Utils::validateArray(Types::string(), $allowedValues))
133
+            throw new \InvalidArgumentException('Ranges::stringOneOf expects arguments of type string only');
134 134
 
135
-		return function ($value) use ($allowedValues)
136
-		{
137
-			return Types::string() && in_array($value, $allowedValues);
138
-		};
139
-	}
135
+        return function ($value) use ($allowedValues)
136
+        {
137
+            return Types::string() && in_array($value, $allowedValues);
138
+        };
139
+    }
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	public static function stringWithLengthBetween(int $minimumLength, int $maximumLength): \Closure
21 21
 	{
22
-		if ($maximumLength < 0 || $maximumLength < 1)
23
-			throw new \InvalidArgumentException('Minimum length cannot be below 0, maximum length cannot be below 1');
22
+		if ($maximumLength < 0 || $maximumLength < 1) {
23
+					throw new \InvalidArgumentException('Minimum length cannot be below 0, maximum length cannot be below 1');
24
+		}
24 25
 
25 26
 		return function ($value) use ($minimumLength, $maximumLength)
26 27
 		{
@@ -36,8 +37,9 @@  discard block
 block discarded – undo
36 37
 	 */
37 38
 	public static function intBetween(int $minimum, int $maximum): \Closure
38 39
 	{
39
-        if ($maximum <= $minimum)
40
-            throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
40
+        if ($maximum <= $minimum) {
41
+                    throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
42
+        }
41 43
         
42 44
 		return function ($value) use ($minimum, $maximum)
43 45
 		{
@@ -53,8 +55,9 @@  discard block
 block discarded – undo
53 55
      */
54 56
     public static function intBetweenExclusive(int $minimum, int $maximum): \Closure
55 57
     {
56
-        if ($maximum <= $minimum)
57
-            throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
58
+        if ($maximum <= $minimum) {
59
+                    throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
60
+        }
58 61
         
59 62
         return function ($value) use ($minimum, $maximum)
60 63
         {
@@ -70,8 +73,9 @@  discard block
 block discarded – undo
70 73
 	 */
71 74
 	public static function floatBetween(float $minimum, float $maximum): \Closure
72 75
 	{
73
-        if ($maximum <= $minimum)
74
-            throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
76
+        if ($maximum <= $minimum) {
77
+                    throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
78
+        }
75 79
         
76 80
 		return function ($value) use ($minimum, $maximum)
77 81
 		{
@@ -87,8 +91,9 @@  discard block
 block discarded – undo
87 91
      */
88 92
     public static function floatBetweenExclusive(float $minimum, float $maximum): \Closure
89 93
     {
90
-        if ($maximum <= $minimum)
91
-            throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
94
+        if ($maximum <= $minimum) {
95
+                    throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.');
96
+        }
92 97
         
93 98
         return function ($value) use ($minimum, $maximum)
94 99
         {
@@ -129,8 +134,9 @@  discard block
 block discarded – undo
129 134
 	 */
130 135
 	public static function stringOneOf(...$allowedValues): \Closure
131 136
 	{
132
-		if (!Utils::validateArray(Types::string(), $allowedValues))
133
-			throw new \InvalidArgumentException('Ranges::stringOneOf expects arguments of type string only');
137
+		if (!Utils::validateArray(Types::string(), $allowedValues)) {
138
+					throw new \InvalidArgumentException('Ranges::stringOneOf expects arguments of type string only');
139
+		}
134 140
 
135 141
 		return function ($value) use ($allowedValues)
136 142
 		{
Please login to merge, or discard this patch.
src/Types.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
 
11 11
 class Types
12 12
 {
13
-	/**
14
-	 * @return \Closure
15
-	 */
16
-	public static function string(): \Closure
17
-	{
18
-		return Utils::createClosureFromCallable('is_string');
19
-	}
13
+    /**
14
+     * @return \Closure
15
+     */
16
+    public static function string(): \Closure
17
+    {
18
+        return Utils::createClosureFromCallable('is_string');
19
+    }
20 20
 
21
-	/**
22
-	 * @return \Closure
23
-	 */
24
-	public static function int(): \Closure
25
-	{
26
-		return Utils::createClosureFromCallable('is_int');
27
-	}
21
+    /**
22
+     * @return \Closure
23
+     */
24
+    public static function int(): \Closure
25
+    {
26
+        return Utils::createClosureFromCallable('is_int');
27
+    }
28 28
 
29
-	/**
30
-	 * @return \Closure
31
-	 */
32
-	public static function float(): \Closure
33
-	{
34
-		return Utils::createClosureFromCallable('is_float');
35
-	}
29
+    /**
30
+     * @return \Closure
31
+     */
32
+    public static function float(): \Closure
33
+    {
34
+        return Utils::createClosureFromCallable('is_float');
35
+    }
36 36
 
37
-	/**
38
-	 * @return \Closure
39
-	 */
40
-	public static function boolean(): \Closure
41
-	{
42
-		return Utils::createClosureFromCallable('is_bool');
43
-	}
37
+    /**
38
+     * @return \Closure
39
+     */
40
+    public static function boolean(): \Closure
41
+    {
42
+        return Utils::createClosureFromCallable('is_bool');
43
+    }
44 44
 
45
-	/**
46
-	 * @return \Closure
47
-	 */
48
-	public static function array(): \Closure
49
-	{
50
-		return Utils::createClosureFromCallable('is_array');
51
-	}
45
+    /**
46
+     * @return \Closure
47
+     */
48
+    public static function array(): \Closure
49
+    {
50
+        return Utils::createClosureFromCallable('is_array');
51
+    }
52 52
 
53
-	/**
54
-	 * @return \Closure
55
-	 */
56
-	public static function callable(): \Closure
57
-	{
58
-		return Utils::createClosureFromCallable('is_callable');
59
-	}
53
+    /**
54
+     * @return \Closure
55
+     */
56
+    public static function callable(): \Closure
57
+    {
58
+        return Utils::createClosureFromCallable('is_callable');
59
+    }
60 60
 
61
-	/**
62
-	 * @return \Closure
63
-	 */
64
-	public static function object(): \Closure
65
-	{
66
-		return Utils::createClosureFromCallable('is_object');
67
-	}
61
+    /**
62
+     * @return \Closure
63
+     */
64
+    public static function object(): \Closure
65
+    {
66
+        return Utils::createClosureFromCallable('is_object');
67
+    }
68 68
 
69 69
     /**
70 70
      * @return \Closure
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
     public static function numeric(): \Closure
73 73
     {
74 74
         return Utils::createClosureFromCallable('is_numeric');
75
-	}
75
+    }
76 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
-	}
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 89
 }
90 90
\ No newline at end of file
Please login to merge, or discard this patch.
src/Reflection.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -36,38 +36,38 @@
 block discarded – undo
36 36
  */
37 37
 class Reflection
38 38
 {
39
-	/**
40
-	 * @param string $class
41
-	 *
42
-	 * @return \ReflectionClass
43
-	 */
44
-	public static function createReflectionObject(string $class): \ReflectionClass
45
-	{
46
-		if (!class_exists($class))
47
-			throw new \InvalidArgumentException('The given class does not exist');
39
+    /**
40
+     * @param string $class
41
+     *
42
+     * @return \ReflectionClass
43
+     */
44
+    public static function createReflectionObject(string $class): \ReflectionClass
45
+    {
46
+        if (!class_exists($class))
47
+            throw new \InvalidArgumentException('The given class does not exist');
48 48
 
49
-		return new \ReflectionClass($class);
50
-	}
49
+        return new \ReflectionClass($class);
50
+    }
51 51
 
52
-	/**
53
-	 * @param string $method
54
-	 * @param array $arguments
55
-	 *
56
-	 * @return \Closure
57
-	 */
58
-	public static function __callStatic(string $method, array $arguments): \Closure
59
-	{
60
-		if (!method_exists(\ReflectionClass::class, $method))
61
-			throw new \InvalidArgumentException('Cannot create closure from method ReflectionClass::' . $method . ', it does not exist');
52
+    /**
53
+     * @param string $method
54
+     * @param array $arguments
55
+     *
56
+     * @return \Closure
57
+     */
58
+    public static function __callStatic(string $method, array $arguments): \Closure
59
+    {
60
+        if (!method_exists(\ReflectionClass::class, $method))
61
+            throw new \InvalidArgumentException('Cannot create closure from method ReflectionClass::' . $method . ', it does not exist');
62 62
 
63
-		return function ($value) use ($method, $arguments)
64
-		{
65
-			if (!Types::string()($value))
66
-				return false;
63
+        return function ($value) use ($method, $arguments)
64
+        {
65
+            if (!Types::string()($value))
66
+                return false;
67 67
 
68
-			$reflection = static::createReflectionObject($value);
68
+            $reflection = static::createReflectionObject($value);
69 69
 
70
-			return call_user_func_array([$reflection, $method], $arguments);
71
-		};
72
-	}
70
+            return call_user_func_array([$reflection, $method], $arguments);
71
+        };
72
+    }
73 73
 }
74 74
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,8 +43,9 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static function createReflectionObject(string $class): \ReflectionClass
45 45
 	{
46
-		if (!class_exists($class))
47
-			throw new \InvalidArgumentException('The given class does not exist');
46
+		if (!class_exists($class)) {
47
+					throw new \InvalidArgumentException('The given class does not exist');
48
+		}
48 49
 
49 50
 		return new \ReflectionClass($class);
50 51
 	}
@@ -57,13 +58,15 @@  discard block
 block discarded – undo
57 58
 	 */
58 59
 	public static function __callStatic(string $method, array $arguments): \Closure
59 60
 	{
60
-		if (!method_exists(\ReflectionClass::class, $method))
61
-			throw new \InvalidArgumentException('Cannot create closure from method ReflectionClass::' . $method . ', it does not exist');
61
+		if (!method_exists(\ReflectionClass::class, $method)) {
62
+					throw new \InvalidArgumentException('Cannot create closure from method ReflectionClass::' . $method . ', it does not exist');
63
+		}
62 64
 
63 65
 		return function ($value) use ($method, $arguments)
64 66
 		{
65
-			if (!Types::string()($value))
66
-				return false;
67
+			if (!Types::string()($value)) {
68
+							return false;
69
+			}
67 70
 
68 71
 			$reflection = static::createReflectionObject($value);
69 72
 
Please login to merge, or discard this patch.
src/Utils.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
 
11 11
 class Utils
12 12
 {
13
-	/**
14
-	 * @param \Closure $closure
15
-	 *
16
-	 * @return \Closure
17
-	 */
18
-	public static function invert(\Closure $closure): \Closure
19
-	{
20
-		return function ($value) use ($closure)
21
-		{
22
-			return !$closure($value);
23
-		};
24
-	}
13
+    /**
14
+     * @param \Closure $closure
15
+     *
16
+     * @return \Closure
17
+     */
18
+    public static function invert(\Closure $closure): \Closure
19
+    {
20
+        return function ($value) use ($closure)
21
+        {
22
+            return !$closure($value);
23
+        };
24
+    }
25 25
 
26
-	/**
27
-	 * @param \Closure $closure1
28
-	 * @param \Closure $closure2
29
-	 *
30
-	 * @return \Closure
31
-	 */
32
-	public static function merge(\Closure $closure1, \Closure $closure2): \Closure
33
-	{
34
-		return function ($value) use ($closure1, $closure2)
35
-		{
36
-			return $closure1($value) || $closure2($value);
37
-		};
38
-	}
26
+    /**
27
+     * @param \Closure $closure1
28
+     * @param \Closure $closure2
29
+     *
30
+     * @return \Closure
31
+     */
32
+    public static function merge(\Closure $closure1, \Closure $closure2): \Closure
33
+    {
34
+        return function ($value) use ($closure1, $closure2)
35
+        {
36
+            return $closure1($value) || $closure2($value);
37
+        };
38
+    }
39 39
 
40
-	/**
41
-	 * @param \Closure $closure1
42
-	 * @param \Closure $closure2
43
-	 *
44
-	 * @return \Closure
45
-	 */
46
-	public static function both(\Closure $closure1, \Closure $closure2): \Closure
47
-	{
48
-		return function ($value) use ($closure1, $closure2)
49
-		{
50
-			return $closure1($value) && $closure2($value);
51
-		};
52
-	}
40
+    /**
41
+     * @param \Closure $closure1
42
+     * @param \Closure $closure2
43
+     *
44
+     * @return \Closure
45
+     */
46
+    public static function both(\Closure $closure1, \Closure $closure2): \Closure
47
+    {
48
+        return function ($value) use ($closure1, $closure2)
49
+        {
50
+            return $closure1($value) && $closure2($value);
51
+        };
52
+    }
53 53
 
54
-	/**
55
-	 * @param \Closure $closure
56
-	 * @param array $values
57
-	 *
58
-	 * @return bool
59
-	 */
60
-	public static function validateArray(\Closure $closure, array $values): bool
61
-	{
62
-		foreach ($values as $value)
63
-			if (!$closure($value))
64
-				return false;
54
+    /**
55
+     * @param \Closure $closure
56
+     * @param array $values
57
+     *
58
+     * @return bool
59
+     */
60
+    public static function validateArray(\Closure $closure, array $values): bool
61
+    {
62
+        foreach ($values as $value)
63
+            if (!$closure($value))
64
+                return false;
65 65
 
66
-		return true;
67
-	}
66
+        return true;
67
+    }
68 68
 
69 69
     /**
70 70
      * @param callable $callable
@@ -81,5 +81,5 @@  discard block
 block discarded – undo
81 81
         {
82 82
             return $callable($value);
83 83
         };
84
-	}
84
+    }
85 85
 }
86 86
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@  discard block
 block discarded – undo
60 60
 	public static function validateArray(\Closure $closure, array $values): bool
61 61
 	{
62 62
 		foreach ($values as $value)
63
-			if (!$closure($value))
64
-				return false;
63
+			if (!$closure($value)) {
64
+							return false;
65
+			}
65 66
 
66 67
 		return true;
67 68
 	}
@@ -74,8 +75,9 @@  discard block
 block discarded – undo
74 75
     public static function createClosureFromCallable(callable $callable)
75 76
     {
76 77
         // Closure::fromCallable was introduced in PHP 7.1.0
77
-        if (version_compare(PHP_VERSION, '7.1.0', '>='))
78
-            return \Closure::fromCallable($callable);
78
+        if (version_compare(PHP_VERSION, '7.1.0', '>=')) {
79
+                    return \Closure::fromCallable($callable);
80
+        }
79 81
         
80 82
         return function ($value) use ($callable)
81 83
         {
Please login to merge, or discard this patch.