getValues(); return isset($values[$name]) ? $values[$name] : null; } public function getValues() { if (! empty($_POST)) return $_POST; $result = json_decode($this->getBody(), true); if ($result) return $result; return array(); } public function getBody() { return file_get_contents('php://input'); } public function getFileContent($name) { if (isset($_FILES[$name])) { return file_get_contents($_FILES[$name]['tmp_name']); } return ''; } public function isPost() { return isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST'; } public function isAjax() { return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'; } }