44 lines
992 B
PHP
Executable File
44 lines
992 B
PHP
Executable File
<?php
|
|
|
|
|
|
namespace Venom\Core;
|
|
|
|
|
|
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)
|
|
{
|
|
return $this->arguments[$key] ?? $default;
|
|
}
|
|
|
|
public function setItem(string $key, $item): void
|
|
{
|
|
$this->arguments[$key] = $item;
|
|
}
|
|
|
|
public function hasItem(string $key): bool
|
|
{
|
|
return isset($this->arguments[$key]);
|
|
}
|
|
} |