| @@ -26,40 +26,40 @@ | ||
| 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 | - $ordered_arguments = Helper::parseParams( | |
| 50 | - $reflection->getParameters(), | |
| 51 | - $args | |
| 52 | - ); | |
| 47 | +		try { | |
| 48 | + $reflection = new ReflectionFunction($function); | |
| 49 | + $ordered_arguments = Helper::parseParams( | |
| 50 | + $reflection->getParameters(), | |
| 51 | + $args | |
| 52 | + ); | |
| 53 | 53 | |
| 54 | - return $reflection->invokeArgs($ordered_arguments); | |
| 55 | -        } catch (Exception $exception) { | |
| 56 | - throw new InvalidArgumentException( | |
| 57 | - sprintf( | |
| 58 | -                    _('Failed to invoke function "%1$s". Reason: %2$s'), | |
| 59 | - $function, | |
| 60 | - $exception->getMessage() | |
| 61 | - ) | |
| 62 | - ); | |
| 63 | - } | |
| 64 | - } | |
| 54 | + return $reflection->invokeArgs($ordered_arguments); | |
| 55 | +		} catch (Exception $exception) { | |
| 56 | + throw new InvalidArgumentException( | |
| 57 | + sprintf( | |
| 58 | +					_('Failed to invoke function "%1$s". Reason: %2$s'), | |
| 59 | + $function, | |
| 60 | + $exception->getMessage() | |
| 61 | + ) | |
| 62 | + ); | |
| 63 | + } | |
| 64 | + } | |
| 65 | 65 | } | 
| @@ -27,41 +27,41 @@ | ||
| 27 | 27 | trait InstantiatorTrait | 
| 28 | 28 |  { | 
| 29 | 29 | |
| 30 | - /** | |
| 31 | - * Check the accepted arguments for a given class constructor and pass | |
| 32 | - * associative array values in the right order. | |
| 33 | - * | |
| 34 | - * @since 0.2.0 | |
| 35 | - * | |
| 36 | - * @param string $class The class that needs to be instantiated. | |
| 37 | - * @param array $args Associative array that contains the arguments. | |
| 38 | - * | |
| 39 | - * @return object Instantiated object. | |
| 40 | - * @throws InvalidArgumentException If a valid method is missing. | |
| 41 | - */ | |
| 42 | - protected function instantiateClass($class, array $args) | |
| 43 | -    { | |
| 44 | -        try { | |
| 45 | - $reflectionMethod = new ReflectionMethod($class, '__construct'); | |
| 30 | + /** | |
| 31 | + * Check the accepted arguments for a given class constructor and pass | |
| 32 | + * associative array values in the right order. | |
| 33 | + * | |
| 34 | + * @since 0.2.0 | |
| 35 | + * | |
| 36 | + * @param string $class The class that needs to be instantiated. | |
| 37 | + * @param array $args Associative array that contains the arguments. | |
| 38 | + * | |
| 39 | + * @return object Instantiated object. | |
| 40 | + * @throws InvalidArgumentException If a valid method is missing. | |
| 41 | + */ | |
| 42 | + protected function instantiateClass($class, array $args) | |
| 43 | +	{ | |
| 44 | +		try { | |
| 45 | + $reflectionMethod = new ReflectionMethod($class, '__construct'); | |
| 46 | 46 | |
| 47 | - $ordered_arguments = Helper::parseParams( | |
| 48 | - $reflectionMethod->getParameters(), | |
| 49 | - $args | |
| 50 | - ); | |
| 47 | + $ordered_arguments = Helper::parseParams( | |
| 48 | + $reflectionMethod->getParameters(), | |
| 49 | + $args | |
| 50 | + ); | |
| 51 | 51 | |
| 52 | - $reflectionClass = new ReflectionClass($class); | |
| 52 | + $reflectionClass = new ReflectionClass($class); | |
| 53 | 53 | |
| 54 | - return $reflectionClass->newInstanceArgs( | |
| 55 | - (array)$ordered_arguments | |
| 56 | - ); | |
| 57 | -        } catch (Exception $exception) { | |
| 58 | - throw new InvalidArgumentException( | |
| 59 | - sprintf( | |
| 60 | -                    _('Failed to instantiate class "%1$s". Reason: %2$s'), | |
| 61 | - $class, | |
| 62 | - $exception->getMessage() | |
| 63 | - ) | |
| 64 | - ); | |
| 65 | - } | |
| 66 | - } | |
| 54 | + return $reflectionClass->newInstanceArgs( | |
| 55 | + (array)$ordered_arguments | |
| 56 | + ); | |
| 57 | +		} catch (Exception $exception) { | |
| 58 | + throw new InvalidArgumentException( | |
| 59 | + sprintf( | |
| 60 | +					_('Failed to instantiate class "%1$s". Reason: %2$s'), | |
| 61 | + $class, | |
| 62 | + $exception->getMessage() | |
| 63 | + ) | |
| 64 | + ); | |
| 65 | + } | |
| 66 | + } | |
| 67 | 67 | } | 
| @@ -52,7 +52,7 @@ | ||
| 52 | 52 | $reflectionClass = new ReflectionClass($class); | 
| 53 | 53 | |
| 54 | 54 | return $reflectionClass->newInstanceArgs( | 
| 55 | - (array)$ordered_arguments | |
| 55 | + (array) $ordered_arguments | |
| 56 | 56 | ); | 
| 57 | 57 |          } catch (Exception $exception) { | 
| 58 | 58 | throw new InvalidArgumentException( | 
| @@ -26,42 +26,42 @@ | ||
| 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 | - protected 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 | + protected 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 | - $ordered_arguments = Helper::parseParams( | |
| 51 | - $reflection->getParameters(), | |
| 52 | - $args | |
| 53 | - ); | |
| 48 | +		try { | |
| 49 | + $reflection = new ReflectionMethod(get_class($object), $method); | |
| 50 | + $ordered_arguments = Helper::parseParams( | |
| 51 | + $reflection->getParameters(), | |
| 52 | + $args | |
| 53 | + ); | |
| 54 | 54 | |
| 55 | - return $reflection->invokeArgs($object, $ordered_arguments); | |
| 56 | -        } catch (Exception $exception) { | |
| 57 | - throw new InvalidArgumentException( | |
| 58 | - sprintf( | |
| 59 | -                    _('Failed to invoke method "%1$s" of class "%2$s". Reason: %3$s'), | |
| 60 | - $method, | |
| 61 | - get_class($object), | |
| 62 | - $exception->getMessage() | |
| 63 | - ) | |
| 64 | - ); | |
| 65 | - } | |
| 66 | - } | |
| 55 | + return $reflection->invokeArgs($object, $ordered_arguments); | |
| 56 | +		} catch (Exception $exception) { | |
| 57 | + throw new InvalidArgumentException( | |
| 58 | + sprintf( | |
| 59 | +					_('Failed to invoke method "%1$s" of class "%2$s". Reason: %3$s'), | |
| 60 | + $method, | |
| 61 | + get_class($object), | |
| 62 | + $exception->getMessage() | |
| 63 | + ) | |
| 64 | + ); | |
| 65 | + } | |
| 66 | + } | |
| 67 | 67 | } |