primo commit
This commit is contained in:
46
libraries/vendor/willdurand/negotiation/src/Negotiation/Accept.php
vendored
Normal file
46
libraries/vendor/willdurand/negotiation/src/Negotiation/Accept.php
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Negotiation;
|
||||
|
||||
use Negotiation\Exception\InvalidMediaType;
|
||||
|
||||
final class Accept extends BaseAccept implements AcceptHeader
|
||||
{
|
||||
private $basePart;
|
||||
|
||||
private $subPart;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
|
||||
if ($this->type === '*') {
|
||||
$this->type = '*/*';
|
||||
}
|
||||
|
||||
$parts = explode('/', $this->type);
|
||||
|
||||
if (count($parts) !== 2 || !$parts[0] || !$parts[1]) {
|
||||
throw new InvalidMediaType();
|
||||
}
|
||||
|
||||
$this->basePart = $parts[0];
|
||||
$this->subPart = $parts[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubPart()
|
||||
{
|
||||
return $this->subPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePart()
|
||||
{
|
||||
return $this->basePart;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user