/ContentNegotiation

PHP implementation of server-driven negotiation

Primary LanguagePHPMIT LicenseMIT

Content Negotiation

PHP implementation of server-driven negotiation

Specification:

Installation

ContentNegotiation requires php >= 5.4

Install CollectionJson with Composer

{
    "require": {
        "mvieira/content-negotiation": "dev-master"
    }
}

Contributing

$ git clone git@github.com:mickaelvieira/ContentNegotiation.git
$ cd ContentNegotiation
$ composer install

Run the test

The test suite has been written with PHPSpec

$ ./bin/phpspec run --format=pretty

PHP Code Sniffer

This project follows the coding style guide PSR2

$ ./bin/phpcs --standard=PSR2 ./src/

Documentation

use ContentNegotiation\Negotiation;

$negotiation = new Negotiation(getallheaders());

$media    = $negotiation->getMedia(['application/json', 'application/xml']);
$language = $negotiation->getLanguage(['en', 'fr']);
$charset  = $negotiation->getCharset(['utf-8']);