for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace W2w\Lib\Apie\Encodings;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
class ChainedFormatRetriever implements FormatRetrieverInterface
{
/**
* @var FormatRetrieverInterface[]
*/
private $formatRetrievers;
* @param FormatRetrieverInterface[]
public function __construct(array $formatRetrievers)
$this->formatRetrievers = $formatRetrievers;
}
* @param string $contentType
* @return string|null
public function getFormat(string $contentType): ?string
foreach ($this->formatRetrievers as $formatRetriever) {
$res = $formatRetriever->getFormat($contentType);
if (!is_null($res)) {
return $res;
throw new NotAcceptableHttpException('"' . $contentType . '" is not accepted');
* @param string $format
public function getContentType(string $format): ?string
$res = $formatRetriever->getContentType($format);
throw new NotAcceptableHttpException('"' . $format . '" is not accepted');