Skip to content

Commit

Permalink
Fix URI template
Browse files Browse the repository at this point in the history
  • Loading branch information
nohponex committed Feb 21, 2016
1 parent cc22534 commit 321ada0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Models/Compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function decompress(
/**
* @throws \Exception
*/
private static function uncompressZip(
private static function decompressZip(
$compressedFile,
$destinationFolder,
$originalFilename = null,
Expand Down
10 changes: 5 additions & 5 deletions src/URIStrategy/IURIStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ interface IURIStrategy
{
/**
* Invoke URIStrategy, the implementation of this method MUST associate the
* request and invoke the apropriate method to handle this request.
* request and invoke the appropriate method to handle this request.
* Invokes to handler method MUST at least define
* `$requestParameters, $requestMethod, $requestHeaders` as arguments.
* NotFoundException SHOULD be when associatation between the request and
* NotFoundException SHOULD be when association between the request and
* handler is not defined
* UnauthorizedException SHOULD be thrown when a request requires authorization
* @param object $requestParameters Request parameters
* @param string $requestMethod HTTP request method
* @param array $requestHeaders Request headers
* @param object|false $requestUser Use object if successful
* authenticated otherwise false
* @return string[2] This method SHOULD return a tuple specifing at least
* @return string[2] This method SHOULD return a tuple specifying at least
* `[$class, $method]` on success.
* @throws Phramework\Exceptions\NotFoundException
* @throws Phramework\Exceptions\UnauthorizedException
* @throws \Phramework\Exceptions\NotFoundException
* @throws \Phramework\Exceptions\UnauthorizedException
*/
public function invoke(
&$requestParameters,
Expand Down
12 changes: 6 additions & 6 deletions src/URIStrategy/URITemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public function addTemplates($templates)
* @return false|array If the validation of the template is not successful
* then false will be returned,
* else a array with a key-value array in position 0 will be returned
* containing the extracter parameters from the URI template.
* containing the extracted parameters from the URI template.
* @todo provide options to specify parameters data type (alphanumeric or int)
* @todo provide options to define optional parameters
*/
public function test($URITemplate, $URI)
{
$template = trim($URITemplate, '/');

// espace slash / character
// escape slash / character
$template = str_replace('/', '\/', $template);
// replace all named parameters {id} to named regexp matches
$template = preg_replace(
Expand Down Expand Up @@ -133,14 +133,14 @@ public static function URI()

$URI = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');

$URI = '/' . trim(str_replace($URI, '', $REDIRECT_URL), '/');
$URI = '/' . trim(str_replace($URI . '/', '', $REDIRECT_URL), '/');
$URI = urldecode($URI) . '/';

$URI = trim($URI, '/');

$parameters = [];

//Extract parametrs from QUERY string
//Extract parameters from QUERY string
parse_str($REDIRECT_QUERY_STRING, $parameters);

return [$URI, $parameters];
Expand All @@ -153,8 +153,8 @@ public static function URI()
* @param array $requestHeaders Request headers
* @param object|false $requestUser Use object if successful
* authenticated otherwise false
* @throws Phramework\Exceptions\NotFoundException
* @throws Phramework\Exceptions\UnauthorizedException
* @throws \Phramework\Exceptions\NotFoundException
* @throws \Phramework\Exceptions\UnauthorizedException
* @todo Use named parameters in future if available by PHP
* @return string[2] This method should return `[$class, $method]` on success
*/
Expand Down

0 comments on commit 321ada0

Please sign in to comment.