Passed
Push — master ( 581880...3137a4 )
by Alain
02:25
created
src/FunctionInvokerTrait.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     public function invokeFunction($function, array $args = array())
41 41
     {
42 42
 
43
-        if (! $function || ! is_string($function) || '' === $function) {
43
+        if ( ! $function || ! is_string($function) || '' === $function) {
44 44
             throw new InvalidArgumentException(_('Missing valid function to invoke.'));
45 45
         }
46 46
 
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -26,45 +26,45 @@
 block discarded – undo
26 26
 trait FunctionInvokerTrait
27 27
 {
28 28
 
29
-    /**
30
-     * Check the accepted arguments for a given function and pass associative
31
-     * array values in the right order.
32
-     *
33
-     * @since 0.1.0
34
-     *
35
-     * @param  string $function Name of the function to invoke.
36
-     * @param  array  $args     Associative array that contains the arguments.
37
-     * @return mixed            Return value of the invoked function.
38
-     * @throws InvalidArgumentException If a valid function is missing.
39
-     */
40
-    public function invokeFunction($function, array $args = array())
41
-    {
29
+	/**
30
+	 * Check the accepted arguments for a given function and pass associative
31
+	 * array values in the right order.
32
+	 *
33
+	 * @since 0.1.0
34
+	 *
35
+	 * @param  string $function Name of the function to invoke.
36
+	 * @param  array  $args     Associative array that contains the arguments.
37
+	 * @return mixed            Return value of the invoked function.
38
+	 * @throws InvalidArgumentException If a valid function is missing.
39
+	 */
40
+	public function invokeFunction($function, array $args = array())
41
+	{
42 42
 
43
-        if (! $function || ! is_string($function) || '' === $function) {
44
-            throw new InvalidArgumentException(_('Missing valid function to invoke.'));
45
-        }
43
+		if (! $function || ! is_string($function) || '' === $function) {
44
+			throw new InvalidArgumentException(_('Missing valid function to invoke.'));
45
+		}
46 46
 
47
-        try {
48
-            $reflection = new ReflectionFunction($function);
49
-            $pass       = array();
47
+		try {
48
+			$reflection = new ReflectionFunction($function);
49
+			$pass       = array();
50 50
 
51
-            foreach ($reflection->getParameters() as $param) {
52
-                if (array_key_exists($param->getName(), $args)) {
53
-                    $pass[] = $args[$param->getName()];
54
-                } else {
55
-                    $pass[] = $param->getDefaultValue();
56
-                }
57
-            }
51
+			foreach ($reflection->getParameters() as $param) {
52
+				if (array_key_exists($param->getName(), $args)) {
53
+					$pass[] = $args[$param->getName()];
54
+				} else {
55
+					$pass[] = $param->getDefaultValue();
56
+				}
57
+			}
58 58
 
59
-            return $reflection->invokeArgs($pass);
60
-        } catch (Exception $exception) {
61
-            throw new InvalidArgumentException(
62
-                sprintf(
63
-                    _('Failed to invoke function "%1$s". Reason: %2$s'),
64
-                    $function,
65
-                    $exception->getMessage()
66
-                )
67
-            );
68
-        }
69
-    }
59
+			return $reflection->invokeArgs($pass);
60
+		} catch (Exception $exception) {
61
+			throw new InvalidArgumentException(
62
+				sprintf(
63
+					_('Failed to invoke function "%1$s". Reason: %2$s'),
64
+					$function,
65
+					$exception->getMessage()
66
+				)
67
+			);
68
+		}
69
+	}
70 70
 }
Please login to merge, or discard this patch.
src/MethodInvokerTrait.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
     public function invokeMethod($object, $method, array $args = [])
42 42
     {
43 43
 
44
-        if (! $method || ! is_string($method) || '' === $method) {
44
+        if ( ! $method || ! is_string($method) || '' === $method) {
45 45
             throw new InvalidArgumentException(_('Missing valid method to invoke.'));
46 46
         }
47 47
 
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * MethodInvokerTrait
4
- *
5
- * @package   BrightNucleus\Invoker
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * MethodInvokerTrait
4
+	 *
5
+	 * @package   BrightNucleus\Invoker
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\Invoker;
13 13
 
@@ -26,47 +26,47 @@  discard block
 block discarded – undo
26 26
 trait MethodInvokerTrait
27 27
 {
28 28
 
29
-    /**
30
-     * Check the accepted arguments for a given method and pass associative
31
-     * array values in the right order.
32
-     *
33
-     * @since 0.1.0
34
-     *
35
-     * @param  object $object The object that contains the method to invoke.
36
-     * @param  string $method Name of the method to invoke.
37
-     * @param  array  $args   Associative array that contains the arguments.
38
-     * @return mixed          Return value of the invoked method.
39
-     * @throws InvalidArgumentException If a valid method is missing.
40
-     */
41
-    public function invokeMethod($object, $method, array $args = [])
42
-    {
29
+	/**
30
+	 * Check the accepted arguments for a given method and pass associative
31
+	 * array values in the right order.
32
+	 *
33
+	 * @since 0.1.0
34
+	 *
35
+	 * @param  object $object The object that contains the method to invoke.
36
+	 * @param  string $method Name of the method to invoke.
37
+	 * @param  array  $args   Associative array that contains the arguments.
38
+	 * @return mixed          Return value of the invoked method.
39
+	 * @throws InvalidArgumentException If a valid method is missing.
40
+	 */
41
+	public function invokeMethod($object, $method, array $args = [])
42
+	{
43 43
 
44
-        if (! $method || ! is_string($method) || '' === $method) {
45
-            throw new InvalidArgumentException(_('Missing valid method to invoke.'));
46
-        }
44
+		if (! $method || ! is_string($method) || '' === $method) {
45
+			throw new InvalidArgumentException(_('Missing valid method to invoke.'));
46
+		}
47 47
 
48
-        try {
49
-            $reflection = new ReflectionMethod(get_class($object), $method);
50
-            $pass       = array();
48
+		try {
49
+			$reflection = new ReflectionMethod(get_class($object), $method);
50
+			$pass       = array();
51 51
 
52
-            foreach ($reflection->getParameters() as $param) {
53
-                if (array_key_exists($param->getName(), $args)) {
54
-                    $pass[] = $args[$param->getName()];
55
-                } else {
56
-                    $pass[] = $param->getDefaultValue();
57
-                }
58
-            }
52
+			foreach ($reflection->getParameters() as $param) {
53
+				if (array_key_exists($param->getName(), $args)) {
54
+					$pass[] = $args[$param->getName()];
55
+				} else {
56
+					$pass[] = $param->getDefaultValue();
57
+				}
58
+			}
59 59
 
60
-            return $reflection->invokeArgs($object, $pass);
61
-        } catch (Exception $exception) {
62
-            throw new InvalidArgumentException(
63
-                sprintf(
64
-                    _('Failed to invoke method "%1$s" of class "%2$s". Reason: %3$s'),
65
-                    $method,
66
-                    get_class($object),
67
-                    $exception->getMessage()
68
-                )
69
-            );
70
-        }
71
-    }
60
+			return $reflection->invokeArgs($object, $pass);
61
+		} catch (Exception $exception) {
62
+			throw new InvalidArgumentException(
63
+				sprintf(
64
+					_('Failed to invoke method "%1$s" of class "%2$s". Reason: %3$s'),
65
+					$method,
66
+					get_class($object),
67
+					$exception->getMessage()
68
+				)
69
+			);
70
+		}
71
+	}
72 72
 }
Please login to merge, or discard this patch.