ahmard/http-status-codes

Http Status Code Enums

1.0.0 2023-05-04 00:15 UTC

This package is not auto-updated.

Last update: 2024-12-13 06:15:34 UTC


README

Enums of all official http status codes and their descriptions.

Installation

composer require ahmard/http-status-codes

Usage

<?php

require __DIR__ . '/vendor/autoload.php';


$sc = \HttpStatusCodes\StatusCode::CREATED;

// Get Status Code  =>  "201"
$sc->value;

$desc = $sc->describe();

// Get Status Code  =>  "201"
$desc->code;

// Get Status Code Title  => "Created"
$desc->title;

You can also get description of a given status code, the description is copied from Wikipedia.

<?php

$sc = \HttpStatusCodes\StatusCode::CREATED;

// Get Description  =>  "The request has been fulfilled, resulting in the creation of a new resource."
$sc->describe()->desc;