Created
October 7, 2012 10:28
-
-
Save jfsimon/3847794 to your computer and use it in GitHub Desktop.
Content negotiation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Content negotiator. | |
*/ | |
interface NegotiatorInterface | |
{ | |
/** | |
* Adds a qualifier. | |
* | |
* @param VariantQualifierInterface $qualifier | |
*/ | |
function addQualifier(VariantQualifierInterface $qualifier); | |
/** | |
* Finds best variant according to request. | |
* | |
* @param VariantInterface[] $variant | |
* @param Request $request | |
* | |
* @return VariantInterface | |
*/ | |
function findBestVariant(array $variants, Request $request); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A variant of one resource. | |
*/ | |
interface VariantInterface | |
{ | |
/** | |
* Returns document path. | |
* | |
* @return string | |
*/ | |
function getName(); | |
/** | |
* Returns document's content. | |
* | |
* @return string | |
*/ | |
function getContent(); | |
/** | |
* Returns base variant quality. | |
* | |
* @return float | |
*/ | |
function getQuality(); | |
/** | |
* Returns variant mime type. | |
* | |
* @return string | |
*/ | |
function getContentType(); | |
/** | |
* Returns variant charset. | |
* | |
* @return string | |
*/ | |
function getCharset(); | |
/** | |
* Returns variant language. | |
* | |
* @return string | |
*/ | |
function getLanguage(); | |
/** | |
* Returns variant encoding. | |
* | |
* @return string | |
*/ | |
function getEncoding(); | |
/** | |
* Returns variant features. | |
* | |
* @return array | |
*/ | |
function getFeatures(); | |
/** | |
* Returns variant description. | |
* | |
* @return string | |
*/ | |
function getDescription(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Qualifies the request according to one header. | |
*/ | |
interface VariantQualifierInterface | |
{ | |
/** | |
* Returns quality factor for given variant according to given request. | |
* | |
* @param VariantInterface $variant | |
* @param Request $request | |
* | |
* @return float | |
*/ | |
function qualify(VariantInterface $variant, Request $request); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment