Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
naming changed [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorkmaz committed Dec 20, 2018
1 parent f127729 commit 7848962
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Dispatcher
/**
* @var null|string
*/
private $cachedFile;
private $cacheFile;

/**
* @var array
Expand All @@ -43,11 +43,11 @@ class Dispatcher
FastRoute\Dispatcher::NOT_FOUND => 404
];

public function __construct(array $routes, int $defaultReturnType, ?string $cachedFile)
public function __construct(array $routes, int $defaultReturnType, ?string $cacheFile)
{
$this->routes = $routes;
$this->defaultReturnType = $defaultReturnType;
$this->cachedFile = $cachedFile;
$this->cacheFile = $cacheFile;
}

/*
Expand All @@ -56,7 +56,7 @@ public function __construct(array $routes, int $defaultReturnType, ?string $cac
public function dispatcher() : FastRoute\Dispatcher
{
$this->setRouteClosures();
if ($this->cachedFile !== null && file_exists($this->cachedFile)) {
if ($this->cacheFile !== null && file_exists($this->cacheFile)) {
return $this->cachedDispatcher();
}
/**
Expand All @@ -73,20 +73,20 @@ public function dispatcher() : FastRoute\Dispatcher

private function createCachedRoute($routeCollector) : void
{
if ($this->cachedFile !== null && !file_exists($this->cachedFile)) {
if ($this->cacheFile !== null && !file_exists($this->cacheFile)) {
/**
* @var FastRoute\RouteCollector $routeCollector
*/
$dispatchData = $routeCollector->getData();
file_put_contents($this->cachedFile, '<?php return ' . var_export($dispatchData, true) . ';', LOCK_EX);
file_put_contents($this->cacheFile, '<?php return ' . var_export($dispatchData, true) . ';', LOCK_EX);
}
}

private function cachedDispatcher() : FastRoute\Dispatcher\GroupCountBased
{
$dispatchData = include $this->cachedFile;
$dispatchData = require $this->cacheFile;
if (!is_array($dispatchData)) {
throw new InvalidCacheFileException('Invalid cache file "' . $this->cachedFile . '"');
throw new InvalidCacheFileException('Invalid cache file "' . $this->cacheFile . '"');
}
return new FastRoute\Dispatcher\GroupCountBased($dispatchData);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class Router
/**
* @var null|string
*/
private $cachedFile;
private $cacheFile;

/**
* Valid Request Methods array.
Expand Down Expand Up @@ -135,7 +135,7 @@ public function withSubFolder(string $folder) : self
public function withCacheFile(string $fileName) : self
{
$new = clone $this;
$new->cachedFile = $fileName;
$new->cacheFile = $fileName;
return $new;
}

Expand Down Expand Up @@ -203,7 +203,7 @@ private function checkRequestMethodIsValid(string $requestMethod) : void

public function getRoute() : Route
{
$selamiDispatcher = new Dispatcher($this->routes, $this->defaultReturnType, $this->cachedFile);
$selamiDispatcher = new Dispatcher($this->routes, $this->defaultReturnType, $this->cacheFile);
$routeInfo = $selamiDispatcher->dispatcher()
->dispatch($this->method, $this->requestedPath);
return $selamiDispatcher->runDispatcher($routeInfo)
Expand Down

0 comments on commit 7848962

Please sign in to comment.