Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 7902d60

Browse files
author
Simon Yousoufov
committed
Implement NotImplementedHttpException
1 parent 89ad098 commit 7902d60

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Diff for: src/NotImplementedHttpException.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Fuzz\HttpException;
4+
5+
class NotImplementedHttpException extends HttpException
6+
{
7+
/**
8+
* HTTP status code
9+
*
10+
* @const int
11+
*/
12+
const HTTP_CODE = 501;
13+
14+
/**
15+
* Error code storage;
16+
*
17+
* @var string
18+
*/
19+
protected $error_name = 'not_implemented';
20+
21+
/**
22+
* NotFoundHttpException constructor.
23+
*
24+
* @param string $message
25+
* @param string $error_formatted
26+
* @param array $error_data
27+
* @param array $headers
28+
* @param \Exception $previous
29+
*/
30+
public function __construct($message = null, array $error_data = [], $error_formatted = null, array $headers = [], \Exception $previous = null)
31+
{
32+
parent::__construct($message, $error_formatted, $error_data, $headers, self::HTTP_CODE, $previous);
33+
}
34+
}

Diff for: tests/HttpExceptionTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Fuzz\HttpException\MethodNotAllowedHttpException;
1212
use Fuzz\HttpException\NotAcceptableHttpException;
1313
use Fuzz\HttpException\NotFoundHttpException;
14+
use Fuzz\HttpException\NotImplementedHttpException;
1415
use Fuzz\HttpException\PreconditionFailedHttpException;
1516
use Fuzz\HttpException\PreconditionRequiredHttpException;
1617
use Fuzz\HttpException\ServiceUnavailableHttpException;
@@ -184,6 +185,14 @@ public function testUnsupportedMediaTypeHttpException()
184185
$this->assertEquals('unsupported_media_type', $exception->getErrorName());
185186
$this->assertEquals('foo', $exception->getMessage());
186187
}
188+
189+
public function testNotImplementedHttpException()
190+
{
191+
$exception = new NotImplementedHttpException('foo');
192+
$this->assertEquals(501, $exception->getStatusCode());
193+
$this->assertEquals('not_implemented', $exception->getErrorName());
194+
$this->assertEquals('foo', $exception->getMessage());
195+
}
187196
}
188197

189198
class StubException extends HttpException

0 commit comments

Comments
 (0)