Skip to content

Commit

Permalink
Merge pull request #29 from gholol/patch-1
Browse files Browse the repository at this point in the history
[IMPROVEMENT] Implement HTTP422 Unprocessable entity
  • Loading branch information
maximebeaudoin committed Jun 7, 2016
2 parents bf10e85 + f617403 commit a20e338
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

/**
* 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);
}
}

0 comments on commit a20e338

Please sign in to comment.