Source

Carica Io / src / Network / Http / Route / Target.php

Full commit
<?php

namespace Carica\Io\Network\Http\Route {

  use Carica\Io\Network\Http;

  abstract class Target {

    private $_callback = NULL;

    public function __construct(Callable $callback) {
      $this->_callback = $callback;
    }

    public function getCallback() {
      return $this->_callback;
    }

    public function __invoke($request) {
      $parameters = $this->validate($request);
      if (is_array($parameters)) {
        return call_user_func($this->getCallback(), $request, $parameters);
      }
      return FALSE;
    }

    abstract public function validate(Http\Request $request);
  }
}