szurubooru/src/Helpers/InputReader.php

28 lines
604 B
PHP
Raw Normal View History

<?php
namespace Szurubooru\Helpers;
2014-09-09 12:34:57 +02:00
final class InputReader extends \ArrayObject
{
public function __construct()
{
2014-09-09 12:34:57 +02:00
parent::setFlags(parent::ARRAY_AS_PROPS | parent::STD_PROP_LIST);
2014-08-30 23:17:54 +02:00
$_PUT = [];
2014-09-09 12:34:57 +02:00
if (isset($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] === 'PUT')
2014-08-30 23:17:54 +02:00
parse_str(file_get_contents('php://input'), $_PUT);
foreach ([$_GET, $_POST, $_PUT] as $source)
{
foreach ($source as $key => $value)
2014-09-09 12:34:57 +02:00
$this->offsetSet($key, $value);
2014-08-30 23:17:54 +02:00
}
}
2014-09-09 12:34:57 +02:00
public function offsetGet($index)
{
2014-09-09 12:34:57 +02:00
if (!parent::offsetExists($index))
return null;
return parent::offsetGet($index);
}
}