Skip to content

Commit

Permalink
Removed unused options from the Router
Browse files Browse the repository at this point in the history
  • Loading branch information
DaGhostman committed Jul 16, 2015
1 parent 92ebefc commit 9975e8b
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/Wave/Framework/Application/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@

class Router
{
private $prefix;
private $cache = false;
private $cacheFolder = '';

/**
* @var \FastRoute\RouteCollector
*/
protected $collector;

/**
* @var array
*/
protected $namedRoutes = [];
private $prefix;

public function __construct(array $options = [])
{
Expand All @@ -35,10 +31,6 @@ public function __construct(array $options = [])
$this->setPrefix($this->prefix);
}

if ($this->cache === true && is_readable($this->cacheFolder)) {
throw new \RuntimeException('Cache directory is not readable');
}

$this->collector = new RouteCollector(
new Std(),
new GroupCountBased()
Expand All @@ -61,6 +53,15 @@ public function get($pattern, array $callback, $name = null)
return $this;
}

private function addRoute($method, $pattern, array $callback, $name = null)
{
$this->collector->addRoute(strtoupper($method), (string)$this->prefix . $pattern, $callback);

if ($name !== null) {
$this->namedRoutes[$name] = $this->prefix . $pattern;
}
}

public function post($pattern, array $callback, $name = null)
{
$this->addRoute('post', $pattern, $callback, $name);
Expand Down Expand Up @@ -109,15 +110,6 @@ public function group($callback, array $options = [])
return $this;
}

private function addRoute($method, $pattern, array $callback, $name = null)
{
$this->collector->addRoute(strtoupper($method), (string) $this->prefix . $pattern, $callback);

if ($name !== null) {
$this->namedRoutes[$name] = $this->prefix . $pattern;
}
}

public function route($name, array $args = [])
{
if (!array_key_exists($name, $this->namedRoutes)) {
Expand Down

0 comments on commit 9975e8b

Please sign in to comment.