2020-05-31 17:00:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace Venom;
|
|
|
|
|
|
|
|
|
|
|
|
class ArgumentHandler
|
|
|
|
{
|
|
|
|
public static ?ArgumentHandler $instance = null;
|
|
|
|
private array $arguments = [];
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
foreach ($_GET as $key => $item) {
|
|
|
|
$this->arguments[htmlspecialchars($key)] = htmlspecialchars($item);
|
|
|
|
}
|
|
|
|
foreach ($_POST as $key => $item) {
|
|
|
|
$this->arguments[htmlspecialchars($key)] = htmlspecialchars($item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function get(): ArgumentHandler
|
|
|
|
{
|
|
|
|
if (self::$instance == null) {
|
|
|
|
self::$instance = new ArgumentHandler();
|
|
|
|
}
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getItem(string $key, $default = null)
|
|
|
|
{
|
|
|
|
if (isset($this->arguments[$key])) {
|
|
|
|
return $this->arguments[$key];
|
|
|
|
}
|
|
|
|
return $default;
|
|
|
|
}
|
2020-07-24 11:08:07 +02:00
|
|
|
|
|
|
|
public function setItem(string $key, $item)
|
|
|
|
{
|
|
|
|
$this->arguments[$key] = $item;
|
|
|
|
}
|
2020-05-31 17:00:05 +02:00
|
|
|
}
|