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

Commit

Permalink
return type issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehmet Korkmaz committed Mar 23, 2017
1 parent 42e1a24 commit 65472e4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private function extractFolder(string $requestPath, string $folder)
public function add($requestMethods, string $route, string $action, string $returnType = null, string $alias = null)
{
$requestMethodsGiven = is_array($requestMethods) ? (array) $requestMethods : [0 => $requestMethods];
$returnType = $this->checkReturnType($returnType);
$returnType = $this->determineReturnType($returnType);
foreach ($requestMethodsGiven as $requestMethod) {
$this->checkRequestMethodParameterType($requestMethod);
$this->checkRequestMethodIsValid($requestMethod);
Expand Down Expand Up @@ -197,11 +197,12 @@ public function __call(string $method, array $args)
* @param string|null $returnType
* @return string
*/
private function checkReturnType($returnType)
private function determineReturnType(string $returnType)
{
return $returnType === null ?
$this->defaultReturnType :
self::$validReturnTypes[$returnType] ?? $this->defaultReturnType;
if ($returnType === null) {
return $this->defaultReturnType;
}
return in_array($returnType, self::$validReturnTypes, true) ? $returnType : $this->defaultReturnType;
}

/**
Expand Down

0 comments on commit 65472e4

Please sign in to comment.