2017 © Pedro Peláez
 

library status-code

HTTP status code value object implementation in PHP

image

snapshotpl/status-code

HTTP status code value object implementation in PHP

  • Friday, February 19, 2016
  • by snapshotpl
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8,478 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

status-code Build Status

HTTP status code value object implementation in PHP., (*1)

Features

  • validation,
  • auto setup reason phrase (if known),
  • immutable,
  • support PSR-7 Psr\Http\Message\ResponseInterface.

Supported RFCs: * https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html * https://tools.ietf.org/html/rfc4918 * https://tools.ietf.org/html/rfc3229 * https://tools.ietf.org/html/rfc5842 * https://tools.ietf.org/html/rfc7538 * https://tools.ietf.org/html/rfc7540 * https://tools.ietf.org/html/rfc7231 * https://tools.ietf.org/html/rfc2518 * https://tools.ietf.org/html/rfc6585 * https://tools.ietf.org/html/rfc2295 * https://tools.ietf.org/html/rfc2774, (*2)

Supported drafts: * https://tools.ietf.org/html/draft-ietf-httpbis-legally-restricted-status-04, (*3)

Installation

Add to composer:, (*4)

{
    "require": {
        "snapshotpl/status-code": "^1.0"
    }
}

Usage

$statusCode = new StatusCode(404);

$statusCode->isClientError(); // true
$statusCode->isRfc2516() // true
$statusCode->isServerError(); // false

echo $statusCode; // 404 Not Found

You can use it with anny PSR-7 implementation:, (*5)

$response = new Zend\Diactoros\Response();
$statusCode = StatusCode::createFromResponse($response);
echo $statusCode; // 200 OK
$response = new Zend\Diactoros\Response();
$statusCode = new StatusCode(404, 'Not exists');
$newResponse = $statusCode->attachToResponse($response);
echo $newResponse->getStatusCode(); // 404
echo $newResponse->getReasonPhrase(); // Not exists

The Versions

19/02 2016

dev-master

9999999-dev

HTTP status code value object implementation in PHP

  Sources   Download

The Requires

 

The Development Requires

psr-7 http value object status code

19/02 2016

1.0.0

1.0.0.0

HTTP status code value object implementation in PHP

  Sources   Download

The Requires

 

The Development Requires

psr-7 http value object status code