@param $class
@param $method

@throws \Exception
772697
protected function useMethod($class, $method)
    {
        $class = "\\OxApp\\controllers\\" . $class;
        try {
            $controller = new  $class();
        } catch (\Exception $e) {
            throw new \Exception($e);
        }
        if (is_subclass_of($controller, 'Ox\App')) {
            if (!empty($method)) {
                $result = $this->tryRunMethod($controller, $method);
            } else {
                $request = Router::$requestDriver;
                if (!empty($request)) {
                    $result = $this->tryRunMethod($controller, strtolower($request->server->get("REQUEST_METHOD")));
                } else {
                    $result = $this->tryRunMethod($controller, strtolower($_SERVER["REQUEST_METHOD"]));
                }
            }
            $response = new Response(
                $result,
                Response::HTTP_OK
            );
            $response->send();
        } else {
            $this->sandResponseCode(Response::HTTP_METHOD_NOT_ALLOWED);
        }
    }
314968
public static function hasApplied($class, $method) {
		foreach (static::_ids($class, $method) as $id) {
			if (isset(static::$_filters[$id])) {
				return true;
			}
		}
		return false;
	}
1106966
public function callMethod($class, $method, array $args = array())
    {
        $method = $this->findMethod($class, $method);
        $method->setAccessible(true);

        return $method->invokeArgs(
            is_object($class) ? $class : null,
            $args
        );
    }
151885
private function invokeClassMethod($class, $method, $namedParams, $classParams)
    {
        if (!class_exists($class)) {
            throw new \InvalidArgumentException("Class $class does not exist.");
        }

        $object = new $class();

        return $this->invokeObjectMethod($object, $method, $namedParams, $classParams);
    }
703423
public function registerHelper($helper, $class)
    {
        if (array_key_exists($helper, $this->helpers)) {
            throw new Exception("Helper method `$helper` has already been defined");
        }

        $this->helpers[$helper] = $class;
    }
210634
private function initMethod(object $object, string $method, bool $expected): void
    {
        if (!$this->mustBeInitialized($object, $method)) {
            return;
        }

        $this->object = $object;
        $this->method = $method;
        $this->expected = $expected;
    }
1013313
public function offsetGet($method)
        {
            $methods = $this->getConsolidatedMethods();

            if (!isset($methods[$method])) {
                throw new Exception("$method, $this->class");
            }

            return $methods[$method];
        }
1055899
public function getMethodRequiredArgCount($class, string $method): int
    {
        $instance = new \ReflectionMethod($class, $method);
        $count = 0;
        // calculate method defined arguments count
        foreach ($instance->getParameters() as $arg) {
            if (!$arg->isOptional()) {
                $count++;
            }
        }

        return $count;
    }
33042
private static function setKeyAndMethod($driver, $key, $method): void
    {
        $driver->setKey($key);
        if ($method !== null) {
            $driver->setMethod($method);
        }
    }
244722
public function fileController($route, $class, $method = "")
    {
        $file = "../OxApp/controllers/" . $class . "Controller.php";
        $file = str_replace("\\", "/", $file);
        if (is_readable($file) === false) {
            throw new \Exception($file . ' Controller Not Found');
        } else {
            $class .= "Controller";
            try {
                $this->useMethod($class, $method);
                Router::$route = $route;
                Router::$controller = $class;
                Router::$routeCounts += 1;
            } catch (\RuntimeException $e) {
                throw new \Exception($e);
            }
        }
    }
1227607
public void executeMethods(final List<Method> methods) throws Exception {

        for (final Method method : methods) {

            // TODO - curious about the findSuitableInstancesOf ? won't
            // method.getDeclaringClass be ok??

            for (final Object object : findSuitableInstancesOf(method.getDeclaringClass())) {

                method.invoke(object);

            }
        }
    }
287220
protected function createQueuedHandlerCallable($class, $method)
    {
        return function () use ($class, $method) {
            $arguments = array_map(function ($a) {
                return is_object($a) ? clone $a : $a;
            }, func_get_args());

            if ($this->handlerWantsToBeQueued($class, $arguments)) {
                $this->queueHandler($class, $method, $arguments);
            }
        };
    }
890441
protected function throwsBadMethodCallException(/*# string */ $method)
    {
        throw new Exception\BadMethodCallException(
            Message::get(Message::IMMUTABLE_EVENT_METHOD, $method),
            Message::IMMUTABLE_EVENT_METHOD
        );
    }
1352187
public static function fromReflection($class, $method = '__construct')
  {
    // $serviceDefinition = new static($class);
    $serviceDefinitionParameters = array();

    /* @var $reflection \ReflectionClass */
    $reflection = new \ReflectionClass($class);
    if (!$reflection->isInstantiable())
    {
      throw new \InvalidArgumentException("Class $class is not instantiable");
    }

    try {
      $constructor = $reflection->getMethod($method);

      if ($method != '__construct' && !$constructor->isStatic())
      {
        throw new \InvalidArgumentException("$class::$method is not static");
      }

      foreach ($constructor->getParameters() as $param)
      {
        /* @var $param \ReflectionParameter */

        $parameterDefinition = new ArrayParameterDefinition($param->getName());
        if ($param->isDefaultValueAvailable())
        {
          $parameterDefinition->setDefaultValue($param->getDefaultValue());
        }

        $serviceDefinitionParameters[$param->getName()] = $parameterDefinition;
      }
    }
    catch (\ReflectionException $e)
    {
      if ($method !== '__construct') // not ok
      {
        throw $e;
      }
      // ok
      $serviceDefinitionParameters = array();
    }

    return new static($class, $serviceDefinitionParameters, $method);
  }
844635
public function setMethod(string $method): void
    {
        if (!\in_array($method, $this->getAvailableMethods(), true)) {
            throw new SessionException(\sprintf('Method unknowed: %s', $method));
        }

        $this->method = $method;
    }
785161
private function checkMethodExists($className, $methodName)
    {
        if (!$this->isMethodAvailable($className, $methodName)) {
            throw new Exception(Piwik::translate('General_ExceptionMethodNotFound', array($methodName, $className)));
        }
    }
458360
public function addMethod(Method $method): void
    {
        $this->methods[(string) $method->getFqsen()] = $method;
    }