1
|
|
|
<?php namespace Neomerx\JsonApi\Http\Headers; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2015 [email protected] (www.neomerx.com) |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use \Neomerx\JsonApi\Factories\Exceptions; |
20
|
|
|
use \Neomerx\JsonApi\Contracts\Http\Headers\MediaTypeInterface; |
21
|
|
|
use \Neomerx\JsonApi\Contracts\Http\Headers\SupportedExtensionsInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @package Neomerx\JsonApi |
25
|
|
|
*/ |
26
|
|
|
class SupportedExtensions implements SupportedExtensionsInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $extensions; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param string $extensions |
35
|
|
|
*/ |
36
|
3 |
|
public function __construct($extensions = MediaTypeInterface::NO_EXT) |
37
|
|
|
{ |
38
|
3 |
|
$this->setExtensions($extensions); |
39
|
3 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @inheritdoc |
43
|
|
|
*/ |
44
|
3 |
|
public function setExtensions($extensions) |
45
|
|
|
{ |
46
|
3 |
|
is_string($extensions) === true ?: Exceptions::throwInvalidArgument('extensions', $extensions); |
47
|
|
|
|
48
|
3 |
|
$this->extensions = $extensions; |
49
|
3 |
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @inheritdoc |
53
|
|
|
*/ |
54
|
3 |
|
public function getExtensions() |
55
|
|
|
{ |
56
|
3 |
|
return $this->extensions; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|