23cc72c8 |
<?php
namespace MVC\Classe;
|
fa275ca6 |
class HttpMethod
|
23cc72c8 |
{
public $method;
|
fa275ca6 |
protected $data;
|
23cc72c8 |
public function __construct()
{
$this->method = $_SERVER['REQUEST_METHOD'];
$this->acceptResponse();
}
private function acceptResponse()
{
switch ($this->method) {
case 'GET':
break;
case 'POST':
break;
case 'PUT':
|
3fb55a08 |
//$this->data['GET'] = ...
//POST DATA except enctype="multipart/form-data"
|
fa275ca6 |
$this->data = json_decode(file_get_contents("php://input"), true);
|
23cc72c8 |
case 'DELETE':
|
3fb55a08 |
//$this->data['GET'] = ...
//POST DATA except enctype="multipart/form-data"
|
fa275ca6 |
$this->data = json_decode(file_get_contents("php://input"), true);
|
23cc72c8 |
break;
default:
// Requête invalide
header("HTTP/1.0 405 Method Not Allowed");
break;
}
}
|
3fb55a08 |
public function getData()
{
return $this->data;
}
|
23cc72c8 |
}
|