diff --git a/src/AbstractResponse.php b/src/AbstractResponse.php index 4c38079..6d439b3 100644 --- a/src/AbstractResponse.php +++ b/src/AbstractResponse.php @@ -36,6 +36,9 @@ abstract class AbstractResponse implements Response const CODE_METHOD_NOT_ALLOWED = 'GEN-METHOD-NOT-ALLOWED'; const CODE_UNWILLING_TO_PROCESS = 'GEN-UNWILLING-TO-PROCESS'; + + const CODE_UNPROCESSABLE = 'GEN-UNPROCESSABLE'; + /** * HTTP Status code @@ -265,4 +268,16 @@ public function errorUnwillingToProcess($message = 'Server is unwilling to proce { return $this->setStatusCode(431)->withError($message, static::CODE_UNWILLING_TO_PROCESS, $headers); } -} \ No newline at end of file + + /** + * Generates a Response with a 422 HTTP header and a given message. + * + * @param string $message + * @param array $headers + * @return mixed + */ + public function errorUnprocessable($message = 'Unprocessable Entity', array $headers = []) + { + return $this->setStatusCode(422)->withError($message, static::CODE_UNPROCESSABLE, $headers); + } +}