Skip to content

Commit

Permalink
Drop unused params
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Aug 4, 2014
1 parent 4924dd7 commit 2cdfc44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @license Apache Version 2.0, January 2004. http://www.apache.org/licenses
*/
namespace Gt\Request;
use \Gt\Core\ConfigObj;

class Request {

Expand All @@ -28,9 +29,9 @@ class Request {

/**
* @param string $uri The requested absolute uri
* @param \Gt\Core\Obj $config Request configuration object
* @param ConfigObj $config Request configuration object
*/
public function __construct($uri, $config) {
public function __construct($uri, ConfigObj $config) {
$this->uri = $uri;
$this->ext = pathinfo($uri, PATHINFO_EXTENSION);
$this->config = $config;
Expand Down
11 changes: 4 additions & 7 deletions src/Request/Standardiser.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function fixUri($uri, ConfigObj $config) {

$fixed = $this->fixHtmlExtension($fixed, $file, $ext, $config);
$fixed = $this->fixIndexFilename($fixed, $file, $ext, $config);
$fixed = $this->fixTrailingSlash($fixed, $file, $ext, $config);
$fixed = $this->fixTrailingExtSlash($fixed, $file, $ext, $config);
$fixed = $this->fixTrailingSlash($fixed, $ext, $config);
$fixed = $this->fixTrailingExtSlash($fixed, $ext);

return $fixed;
}
Expand Down Expand Up @@ -120,13 +120,12 @@ public function fixIndexFilename($uri, $file, $ext, ConfigObj $config) {
* Also, removes any trailing slashes from an extension-full URI.
*
* @param string $uri The request URI
* @param string $file The requested file name, with no path.
* @param string $ext The requested file extension, or null.
* @param ConfigObj $config The provided configuration options object.
*
* @return string The fixed URI.
*/
public function fixTrailingSlash($uri, $file, $ext, ConfigObj $config) {
public function fixTrailingSlash($uri, $ext, ConfigObj $config) {
if(!isset($config->pageview_trailing_directory_slash)) {
return $uri;
}
Expand Down Expand Up @@ -155,13 +154,11 @@ public function fixTrailingSlash($uri, $file, $ext, ConfigObj $config) {
* URIs with file extensions should not end with a slash, ever.
*
* @param string $uri The request URI
* @param string $file The requested file name, with no path.
* @param string $ext The requested file extension, or null.
* @param ConfigObj $config The provided configuration options object.
*
* @return string The fixed URI.
*/
public function fixTrailingExtSlash($uri, $file, $ext, ConfigObj $config) {
public function fixTrailingExtSlash($uri, $ext) {
$lastChar = substr($uri, -1);
if(!empty($ext) && $lastChar === "/") {
$uri = substr($uri, 0, strrpos($uri, "/"));
Expand Down
10 changes: 5 additions & 5 deletions test/Unit/Request/Standardiser.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ public function testFixTrailingSlash($uri) {
$this->pathinfo($uri, $file, $ext);
$standardiser = new Standardiser();
$this->assertEquals($uri,
$standardiser->fixTrailingSlash($uri, $file, $ext, new ConfigObj()));
$standardiser->fixTrailingSlash($uri, $ext, new ConfigObj()));

$config = new ConfigObj();
$config->pageview_trailing_directory_slash = true;

$fixed = $standardiser->fixTrailingSlash($uri, $file, $ext, $config);
$fixed = $standardiser->fixTrailingSlash($uri, $ext, $config);

$lastChar = substr($uri, -1);
if(empty($ext)) {
Expand All @@ -174,12 +174,12 @@ public function testFixNoTrailingSlash($uri) {
$this->pathinfo($uri, $file, $ext);
$standardiser = new Standardiser();
$this->assertEquals($uri,
$standardiser->fixTrailingSlash($uri, $file, $ext, new ConfigObj()));
$standardiser->fixTrailingSlash($uri, $ext, new ConfigObj()));

$config = new ConfigObj();
$config->pageview_trailing_directory_slash = false;

$fixed = $standardiser->fixTrailingSlash($uri, $file, $ext, $config);
$fixed = $standardiser->fixTrailingSlash($uri, $ext, $config);

$lastChar = substr($uri, -1);
if(empty($ext)) {
Expand All @@ -199,7 +199,7 @@ public function testFixTrailingExtSlash($uri) {
$this->pathinfo($uri, $file, $ext);
$standardiser = new Standardiser();
$fixed = $standardiser->fixTrailingExtSlash(
$uri, $file, $ext, new ConfigObj());
$uri, $ext);

if(!empty($ext)) {
$this->assertStringEndsNotWith("/", $fixed);
Expand Down

0 comments on commit 2cdfc44

Please sign in to comment.