Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Dec 9, 2013
1 parent f2b501f commit 151f78b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,31 @@ $format = $negotiator->getBest($acceptHeader, $priorities);

The `FormatNegotiator` class also provides a `getBestFormat()` method that
returns the best format given an `Accept` header string and a set of
preferred/allowed formats:
preferred/allowed formats or mime types:

``` php
<?php

$negotiator = new \Negotiation\FormatNegotiator();

$acceptHeader = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
$priorities = array('html', 'json', '*/*');
$priorities = array('html', 'application/json', '*/*');

$format = $negotiator->getBestFormat($acceptHeader, $priorities);
// $format = html
```

#### Other Methods

* `registerFormat($format, array $mimeTypes, $override = false)`: registers a new
format with its mime types;
* `getFormat($mimeType)`: returns the format for a given mime type, or null if
not found;
* `getMimeTypes(array $formats)`: returns an array of mime types for the given
set of formats;
* `normalizePriorities($priorities)`: ensures that any formats are converted to
mime types.

### Language Negotiation

Language negotiation is handled by the `LanguageNegotiator` class:
Expand Down

0 comments on commit 151f78b

Please sign in to comment.