<?php
class RequestHelper {

  public function only_allow_post_request() {
    if ($_SERVER["REQUEST_METHOD"] != "POST") {
      http_response_code(405);
      die(0);
    }
  }

  public function only_allow_get_request() {
    if ($_SERVER["REQUEST_METHOD"] != "GET") {
      http_response_code(405);
      die(0);
    }
  }

  public function only_allow_ajax_call() {
    if (!isset($_SERVER["HTTP_X_REQUESTED_WITH"]) || (empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
      http_response_code(405);
      die(0);
    }
  }

}
  