Skip to content

Commit

Permalink
Update request.php
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Aug 1, 2024
1 parent 1565cb1 commit 2113ea5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions upload/system/library/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,62 @@ public function __construct() {
$this->server = $this->clean($_SERVER);
}

public function get(string $key, string $type = ''): mixed {
if (isset($this->get[$key])) {
$value = $this->get[$key];
} else {
$value = null;
}

switch ($type) {
case 'string':
return (string)$value;
break;
case 'int':
return (int)$value;
break;
case 'float':
return (float)$value;
break;
case 'bool':
return (bool)$value;
break;
case 'array':
return (array)$value;
break;
default:
return $value;
}
}

public function post(string $key, string $type = ''): mixed {
if (isset($this->post[$key])) {
$value = $this->post[$key];
} else {
$value = null;
}

switch ($type) {
case 'string':
return (string)$value;
break;
case 'int':
return (int)$value;
break;
case 'float':
return (float)$value;
break;
case 'bool':
return (bool)$value;
break;
case 'array':
return (array)$value;
break;
default:
return $value;
}
}

/**
* Clean
*
Expand Down

0 comments on commit 2113ea5

Please sign in to comment.