yaroslawww/http-statuscodes

PHP library for handling HTTP status codes

0.1.0 2022-04-01 11:24 UTC

This package is auto-updated.

Last update: 2024-10-29 05:41:02 UTC


README

Software License Build Status StyleCI Quality Score Code Coverage PHP Version Packagist Version

Installation

You can install the package via composer:

    composer require yaroslawww/http-statuscodes

Simple example

    $manager = new \HttpStatusCodes\StatusCodeManager();
    $statusCode = $manager->makeStatusCode(201);
    if($statusCode) {
        $statusCode->getMessage();
        $statusCode->getCode();
        $statusCode->getDescription();
        $statusCode->getRFCNumber();
    }
    $manager = new \HttpStatusCodes\StatusCodeManager();
    $statusCode = $manager->makeStatusCode('HTTP_OK');
    if($statusCode) {
        $statusCode->getMessage();
        $statusCode->getCode();
        $statusCode->getDescription();
        $statusCode->getRFCNumber();
    }
    class CustomStatusCodes
    {
        /**
         * @rfc 1133
         * @description Test Description New Ok
         * @message OKAY!
         */
        const HTTP_OKAY = 3333;
    }
    $manager = new \HttpStatusCodes\StatusCodeManager();
    $statusCode = $manager->makeStatusCode(3333);
    if($statusCode) {
        $statusCode->getMessage();
        $statusCode->getCode();
        $statusCode->getDescription();
        $statusCode->getRFCNumber();
    }

Testing

    ./vendor/bin/phpunit
    # or
    composer test

Security

If you discover any security related issues, please email yaroslav.georgitsa@gmail.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.