Files
oficial/aldarien/response/app/Service/Response.php
2021-03-25 21:23:29 -03:00

62 lines
1.1 KiB
PHP

<?php
namespace App\Service;
class Response
{
protected $post;
protected $get;
protected $gump;
public function __construct()
{
$this->gump = new \GUMP();
}
public function sanitize()
{
if ($_POST) {
$this->post = $this->correctNumbers($this->gump->sanitize($_POST));
}
if ($_GET) {
$this->get = $this->correctNumbers($this->gump->sanitize($_GET));
}
}
public function correctNumbers(array $data)
{
$output = [];
foreach ($data as $key => $value) {
if (is_float(str_replace(',', '.', $value))) {
$output[$key] = str_replace(',', '.', $value);
} else {
$output[$key] = $value;
}
}
return $output;
}
public function get($query = null)
{
if ($this->get == null) {
$this->sanitize();
}
if ($query == null) {
return $this->get;
}
if (isset($this->get[$query])) {
return $this->get[$query];
}
return false;
}
public function post($query = null)
{
if ($this->post == null) {
$this->sanitize();
}
if ($query == null) {
return $this->post;
}
if (isset($this->post[$query])) {
return $this->post[$query];
}
return false;
}
}
?>