protected function invokeMethod($object, $method, array $args = [])
    {

        if (! $method || ! is_string($method) || '' === $method) {
            throw new InvalidArgumentException(_('Missing valid method to invoke.'));
        }

        try {
            $reflection        = new ReflectionMethod(get_class($object), $method);
            $ordered_arguments = Helper::parseParams(
                $reflection->getParameters(),
                $args
            );

            return $reflection->invokeArgs($object, $ordered_arguments);
        } catch (Exception $exception) {
            throw new InvalidArgumentException(
                sprintf(
                    _('Failed to invoke method "%1$s" of class "%2$s". Reason: %3$s'),
                    $method,
                    get_class($object),
                    $exception->getMessage()
                )
            );
        }
    }
protected function invokeMethod($object, $method, array $args = [])
    {

        if (! $method || ! is_string($method) || '' === $method) {
            throw new InvalidArgumentException(_('Missing valid method to invoke.'));
        }

        try {
            $reflection        = new ReflectionMethod(get_class($object), $method);
            $ordered_arguments = Helper::parseParams(
                $reflection->getParameters(),
                $args
            );

            return $reflection->invokeArgs($object, $ordered_arguments);
        } catch (Exception $exception) {
            throw new InvalidArgumentException(
                sprintf(
                    _('Failed to invoke method "%1$s" of class "%2$s". Reason: %3$s'),
                    $method,
                    get_class($object),
                    $exception->getMessage()
                )
            );
        }
    }
protected function invokeMethod ( $ object , $ method , array $ args = [ ] ) { if ( ! $ method || ! is_string ( $ method ) || '' === $ method ) { throw new InvalidArgumentException ( _ ( 'Missing valid method to invoke.' ) ) ; } try { $ reflection = new ReflectionMethod ( get_class ( $ object ) , $ method ) ; $ ordered_arguments = Helper :: parseParams ( $ reflection -> getParameters ( ) , $ args ) ; return $ reflection -> invokeArgs ( $ object , $ ordered_arguments ) ; } catch ( Exception $ exception ) { throw new InvalidArgumentException ( sprintf ( _ ( 'Failed to invoke method "%1$s" of class "%2$s". Reason: %3$s' ) , $ method , get_class ( $ object ) , $ exception -> getMessage ( ) ) ) ; } }
Check the accepted arguments for a given method and pass associative
array values in the right order.

@since 0.1.0

@param  object $object The object that contains the method to invoke.
@param  string $method Name of the method to invoke.
@param  array  $args   Associative array that contains the arguments.
@return mixed          Return value of the invoked method.
@throws InvalidArgumentException If a valid method is missing.
Check the accepted arguments for a given method and pass associative array values in the right order .