Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Route & RoutesHelper (add constraints); Update HelperClasses/C…
…oreHelper (add spliceSymbolFirst; spliceSymbolLast)
- Loading branch information
anthsnow
committed
May 18, 2022
1 parent
a4271d6
commit e202eb8
Showing
5 changed files
with
204 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace FlyCubePHP\Core\Routes; | ||
|
||
include_once __DIR__.'/../../HelperClasses/Enum.php'; | ||
|
||
class RouteType extends \FlyCubePHP\HelperClasses\Enum { | ||
const GET = 0; | ||
const POST = 1; | ||
const PUT = 2; | ||
const PATCH = 3; | ||
const DELETE = 4; | ||
|
||
static public function intToString(int $val): string { | ||
switch ($val) { | ||
case RouteType::GET: | ||
return "GET"; | ||
case RouteType::POST: | ||
return "POST"; | ||
case RouteType::PUT: | ||
return "PUT"; | ||
case RouteType::PATCH: | ||
return "PATCH"; | ||
case RouteType::DELETE: | ||
return "DELETE"; | ||
default: | ||
break; | ||
} | ||
return "???"; | ||
} | ||
|
||
static public function stringToInt(string $val): int { | ||
if (empty($val)) | ||
return -1; | ||
$tmpVal = strtolower($val); | ||
if (strcmp($tmpVal, "get") === 0 || strcmp($tmpVal, "head") === 0) | ||
return RouteType::GET; | ||
elseif (strcmp($tmpVal, "post") === 0) | ||
return RouteType::POST; | ||
elseif (strcmp($tmpVal, "put") === 0) | ||
return RouteType::PUT; | ||
elseif (strcmp($tmpVal, "patch") === 0) | ||
return RouteType::PATCH; | ||
elseif (strcmp($tmpVal, "delete") === 0) | ||
return RouteType::DELETE; | ||
return -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.