예제 #1
0
파일: Body.php 프로젝트: kris-nova/API
 /**
  * Based on the body, will attempt to determine a type
  *
  * @return string
  */
 public static function getType()
 {
     //         if (Verbs::getVerb() == v_get) {
     //             return - 1;
     //         }
     $body = Body::getBody();
     $possibleJson = json_decode($body);
     if ($possibleJson) {
         return t_json;
     }
     Error::throwInternalException('The API does not support types other than JSON yet OR you have invalid JSON');
 }
예제 #2
0
파일: Verbs.php 프로젝트: kris-nova/API
 /**
  * Will return the constant for whatever verb the request is using
  * The logic is return on success, without checking for a race condition
  */
 public static function getVerb()
 {
     // Check $_SERVER
     if (!isset($_SERVER['REQUEST_METHOD'])) {
         Error::throwInternalException('Invalid runtime environment. No request type defined.');
     }
     /* GET */
     if (static::isGet()) {
         return v_get;
         /* POST */
     } elseif (static::isPost()) {
         return v_post;
         /* PUT */
     } elseif (static::isPut()) {
         return v_put;
         /* DELETE */
     } elseif (static::isDelete()) {
         return v_delete;
         /* UNKNOWN */
     } else {
         Error::throwInternalException('Unable to determine verb', i_emergency);
     }
 }
예제 #3
0
파일: Validate.php 프로젝트: kris-nova/API
 /**
  * Validation failure
  *
  * @param string $message            
  */
 protected function fail($message = null)
 {
     $backtrace = debug_backtrace();
     $failingMethod = $backtrace[1]['function'];
     Error::throwValidationException($failingMethod, $message);
 }
예제 #4
0
파일: Google.php 프로젝트: kris-nova/API
 public function delete()
 {
     Error::throwApiException('`DELETE` operations are not currently supported for the endpoint ' . $this->request->endpoint, r_missing);
 }
예제 #5
0
파일: Endpoints.php 프로젝트: kris-nova/API
 /**
  * (non-PHPdoc)
  *
  * @see \API\src\Endpoints\EndpointsInterface::delete()
  */
 public function delete()
 {
     Error::throwInternalException('`DELETE` is not defined for endpoint ' . $this->request->endpoint, i_emergency);
 }