1
|
|
|
<?php namespace Neomerx\JsonApi\Encoder; |
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\Encoder\EncodingParametersInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @package Neomerx\JsonApi |
24
|
|
|
*/ |
25
|
|
|
class EncodingParameters implements EncodingParametersInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var array|null |
29
|
|
|
*/ |
30
|
|
|
private $includePaths; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var array|null |
34
|
|
|
*/ |
35
|
|
|
private $fieldSets; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param array|null $includePaths |
39
|
|
|
* @param array|null $fieldSets |
40
|
|
|
*/ |
41
|
88 |
|
public function __construct(array $includePaths = null, array $fieldSets = null) |
42
|
|
|
{ |
43
|
88 |
|
$this->fieldSets = $fieldSets; |
44
|
88 |
|
$this->includePaths = $includePaths; |
45
|
88 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @inheritdoc |
49
|
|
|
*/ |
50
|
72 |
|
public function getIncludePaths() |
51
|
|
|
{ |
52
|
72 |
|
return $this->includePaths; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @inheritdoc |
57
|
|
|
*/ |
58
|
19 |
|
public function getFieldSets() |
59
|
|
|
{ |
60
|
19 |
|
return $this->fieldSets; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @inheritdoc |
65
|
|
|
*/ |
66
|
52 |
|
public function getFieldSet($type) |
67
|
|
|
{ |
68
|
52 |
|
is_string($type) === true ?: Exceptions::throwInvalidArgument('type', $type); |
69
|
|
|
|
70
|
52 |
|
return (isset($this->fieldSets[$type]) === true ? $this->fieldSets[$type] : null); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|