mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Update HttpInput to new standards
This commit is contained in:
parent
bb7baa8a37
commit
74627e9421
1 changed files with 19 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
||||||
<?
|
<?
|
||||||
|
use Safe\DateTimeImmutable;
|
||||||
|
|
||||||
use function Safe\ini_get;
|
use function Safe\ini_get;
|
||||||
use function Safe\preg_match;
|
use function Safe\preg_match;
|
||||||
|
|
||||||
|
@ -141,7 +143,7 @@ class HttpInput{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string>|array<int>|array<float>|array<bool>|string|int|float|bool|null
|
* @return array<string>|array<int>|array<float>|array<bool>|string|int|float|bool|DateTimeImmutable|null
|
||||||
*/
|
*/
|
||||||
private static function GetHttpVar(string $variable, HttpVariableType $type, HttpVariableSource $set): mixed{
|
private static function GetHttpVar(string $variable, HttpVariableType $type, HttpVariableSource $set): mixed{
|
||||||
$vars = [];
|
$vars = [];
|
||||||
|
@ -170,9 +172,12 @@ class HttpInput{
|
||||||
// We asked for not an array, but we got an array
|
// We asked for not an array, but we got an array
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else{
|
elseif(is_string($vars[$variable])){
|
||||||
$var = trim($vars[$variable]);
|
$var = trim($vars[$variable]);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
$var = $vars[$variable];
|
||||||
|
}
|
||||||
|
|
||||||
switch($type){
|
switch($type){
|
||||||
case HttpVariableType::String:
|
case HttpVariableType::String:
|
||||||
|
@ -189,7 +194,7 @@ class HttpInput{
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HttpVariableType::Boolean:
|
case HttpVariableType::Boolean:
|
||||||
if($var === '0' || strtolower($var) == 'false' || strtolower($var) == 'off'){
|
if($var === false || $var === '0' || strtolower($var) == 'false' || strtolower($var) == 'off'){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -205,6 +210,17 @@ class HttpInput{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Enums\HttpVariableType::DateTime:
|
||||||
|
if($var != ''){
|
||||||
|
try{
|
||||||
|
return new DateTimeImmutable($var);
|
||||||
|
}
|
||||||
|
catch(Exception){
|
||||||
|
vdd('q');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue