Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

runs-on: ${{ matrix.operating-system }}

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor/
composer.lock
composer.lock
*.cache
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fix: cbf
vendor/bin/php-cs-fixer fix

.PHONY: test
test: cs
test: cs phpstan
vendor/bin/phpunit

.PHONY: cs
Expand All @@ -17,4 +17,8 @@ cs:

.PHONY: cbf
cbf:
vendor/bin/phpcbf
vendor/bin/phpcbf

.PHONY: phpstan
phpstan:
vendor/bin/phpstan analyse
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ HTTP Status Codes and Exceptions

## Requirements

- **php**: ^7.1 | ^8.0
- **php**: ^7.2 | ^8.0

## Installing

Expand All @@ -21,7 +21,7 @@ composer require 'corpus/http'

## Documentation

### Class: \Corpus\Http\Exceptions\AbstractHttpException
### Class: Corpus\Http\Exceptions\AbstractHttpException

Base Exception class all HTTP Exception Classes Extend

Expand All @@ -39,43 +39,43 @@ Use the HTTP Status code as the base exceptions code.

- ***string*** `$message`

### Class: \Corpus\Http\Exceptions\ClientError\AbstractClientErrorException
### Class: Corpus\Http\Exceptions\ClientError\AbstractClientErrorException

Base of Exceptions Representing The 4xx Class

### Class: \Corpus\Http\Exceptions\ClientError\BadRequestException
### Class: Corpus\Http\Exceptions\ClientError\BadRequestException

#### Method: BadRequestException->getHttpStatusCode

```php
function getHttpStatusCode() : int
```

### Class: \Corpus\Http\Exceptions\ClientError\ForbiddenException
### Class: Corpus\Http\Exceptions\ClientError\ForbiddenException

#### Method: ForbiddenException->getHttpStatusCode

```php
function getHttpStatusCode() : int
```

### Class: \Corpus\Http\Exceptions\ClientError\NotFoundException
### Class: Corpus\Http\Exceptions\ClientError\NotFoundException

#### Method: NotFoundException->getHttpStatusCode

```php
function getHttpStatusCode() : int
```

### Class: \Corpus\Http\Exceptions\ClientError\UnauthorizedException
### Class: Corpus\Http\Exceptions\ClientError\UnauthorizedException

#### Method: UnauthorizedException->getHttpStatusCode

```php
function getHttpStatusCode() : int
```

### Class: \Corpus\Http\Exceptions\Redirection\AbstractLocationRedirectionHttpException
### Class: Corpus\Http\Exceptions\Redirection\AbstractLocationRedirectionHttpException

Base of 3xx Exceptions which include a "Location" header.

Expand All @@ -96,51 +96,51 @@ AbstractRedirectionHttpException constructor.

#### Undocumented Method: `AbstractLocationRedirectionHttpException->getLocation()`

### Class: \Corpus\Http\Exceptions\Redirection\AbstractRedirectionHttpException
### Class: Corpus\Http\Exceptions\Redirection\AbstractRedirectionHttpException

Base of Exceptions Representing The 3xx Class

### Class: \Corpus\Http\Exceptions\Redirection\FoundException
### Class: Corpus\Http\Exceptions\Redirection\FoundException

#### Method: FoundException->getHttpStatusCode

```php
function getHttpStatusCode() : int
```

### Class: \Corpus\Http\Exceptions\Redirection\SeeOtherException
### Class: Corpus\Http\Exceptions\Redirection\SeeOtherException

#### Method: SeeOtherException->getHttpStatusCode

```php
function getHttpStatusCode() : int
```

### Class: \Corpus\Http\Exceptions\ServerError\AbstractServerErrorException
### Class: Corpus\Http\Exceptions\ServerError\AbstractServerErrorException

Base of Exceptions Representing The 5xx Class

### Class: \Corpus\Http\Exceptions\ServerError\InternalServerErrorException
### Class: Corpus\Http\Exceptions\ServerError\InternalServerErrorException

#### Method: InternalServerErrorException->getHttpStatusCode

```php
function getHttpStatusCode() : int
```

### Class: \Corpus\Http\Exceptions\Success\AbstractSuccessException
### Class: Corpus\Http\Exceptions\Success\AbstractSuccessException

Base of Exceptions Representing The 2xx Class

### Class: \Corpus\Http\Exceptions\Success\NoContentException
### Class: Corpus\Http\Exceptions\Success\NoContentException

#### Method: NoContentException->getHttpStatusCode

```php
function getHttpStatusCode() : int
```

### Class: \Corpus\Http\Status
### Class: Corpus\Http\Status

```php
<?php
Expand Down Expand Up @@ -209,6 +209,9 @@ class Status {
public const LoopDetected = 508;
public const NotExtended = 510;
public const NetworkAuthenticationRequired = 511;
/**
* @var array<int,string>
*/
public static $statusText = [self::StatusContinue => 'Continue', self::SwitchingProtocols => 'Switching Protocols', self::Processing => 'Processing', self::EarlyHints => 'Early Hints', self::OK => 'OK', self::Created => 'Created', self::Accepted => 'Accepted', self::NonAuthoritativeInfo => 'Non-Authoritative Information', self::NoContent => 'No Content', self::ResetContent => 'Reset Content', self::PartialContent => 'Partial Content', self::MultiStatus => 'Multi-Status', self::AlreadyReported => 'Already Reported', self::IMUsed => 'IM Used', self::MultipleChoices => 'Multiple Choices', self::MovedPermanently => 'Moved Permanently', self::Found => 'Found', self::SeeOther => 'See Other', self::NotModified => 'Not Modified', self::UseProxy => 'Use Proxy', self::TemporaryRedirect => 'Temporary Redirect', self::PermanentRedirect => 'Permanent Redirect', self::BadRequest => 'Bad Request', self::Unauthorized => 'Unauthorized', self::PaymentRequired => 'Payment Required', self::Forbidden => 'Forbidden', self::NotFound => 'Not Found', self::MethodNotAllowed => 'Method Not Allowed', self::NotAcceptable => 'Not Acceptable', self::ProxyAuthRequired => 'Proxy Authentication Required', self::RequestTimeout => 'Request Timeout', self::Conflict => 'Conflict', self::Gone => 'Gone', self::LengthRequired => 'Length Required', self::PreconditionFailed => 'Precondition Failed', self::RequestEntityTooLarge => 'Request Entity Too Large', self::RequestURITooLong => 'Request URI Too Long', self::UnsupportedMediaType => 'Unsupported Media Type', self::RequestedRangeNotSatisfiable => 'Requested Range Not Satisfiable', self::ExpectationFailed => 'Expectation Failed', self::Teapot => 'I\'m a teapot', self::MisdirectedRequest => 'Misdirected Request', self::UnprocessableEntity => 'Unprocessable Entity', self::Locked => 'Locked', self::FailedDependency => 'Failed Dependency', self::TooEarly => 'Too Early', self::UpgradeRequired => 'Upgrade Required', self::PreconditionRequired => 'Precondition Required', self::TooManyRequests => 'Too Many Requests', self::RequestHeaderFieldsTooLarge => 'Request Header Fields Too Large', self::UnavailableForLegalReasons => 'Unavailable For Legal Reasons', self::InternalServerError => 'Internal Server Error', self::NotImplemented => 'Not Implemented', self::BadGateway => 'Bad Gateway', self::ServiceUnavailable => 'Service Unavailable', self::GatewayTimeout => 'Gateway Timeout', self::HTTPVersionNotSupported => 'HTTP Version Not Supported', self::VariantAlsoNegotiates => 'Variant Also Negotiates', self::InsufficientStorage => 'Insufficient Storage', self::LoopDetected => 'Loop Detected', self::NotExtended => 'Not Extended', self::NetworkAuthenticationRequired => 'Network Authentication Required'];
}
```
Expand All @@ -221,7 +224,7 @@ function statusText(int $code) : ?string

Return the text for an HTTP status code.

### Class: \Corpus\Http\StatusAwareInterface
### Class: Corpus\Http\StatusAwareInterface

#### Method: StatusAwareInterface->getHttpStatusCode

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^7.1 | ^8.0"
"php": "^7.2 | ^8.0"
},
"autoload": {
"psr-4": {
Expand All @@ -21,7 +21,8 @@
"phpunit/phpunit": "~7.5 | ~9.0",
"squizlabs/php_codesniffer": "^3.5",
"corpus/coding-standard": "^0.6.0",
"friendsofphp/php-cs-fixer": "^2.17"
"friendsofphp/php-cs-fixer": "^2.17",
"phpstan/phpstan": "^1.12"
},
"config": {
"allow-plugins": {
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 9
paths:
- src
phpVersion: 70200
1 change: 1 addition & 0 deletions src/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ abstract class Status {
public const NotExtended = 510; // RFC 2774, 7
public const NetworkAuthenticationRequired = 511; // RFC 6585, 6

/** @var array<int,string> */
public static $statusText = [
self::StatusContinue => 'Continue',
self::SwitchingProtocols => 'Switching Protocols',
Expand Down