for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Equip\Exception;
use Psr\Http\Message\ResponseInterface;
use RuntimeException;
class HttpException extends RuntimeException
{
/**
* @param string $path
*
* @return static
*/
public static function notFound($path)
return new static(sprintf(
'Cannot find any resource at `%s`',
$path
), 404);
}
* @param string $method
* @param array $allowed
public static function methodNotAllowed($path, $method, array $allowed)
$error = new static(sprintf(
'Cannot access resource `%s` using method `%s`',
$path,
$method
), 405);
$error->allowed = $allowed;
return $error;
* @param string $message
public static function badRequest($message)
'Cannot parse the request: %s',
$message
), 400);
* @var array
private $allowed = [];
* @param ResponseInterface $response
* @return ResponseInterface
public function withResponse(ResponseInterface $response)
if (!empty($this->allowed)) {
$response = $response->withHeader('Allow', implode(',', $this->allowed));
return $response;