1 | <?php |
||
24 | class DecodersFactory implements DecodersFactoryInterface |
||
25 | { |
||
26 | /** |
||
27 | * Decoders map |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $map; |
||
32 | |||
33 | /** |
||
34 | * Decoders instances |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $instances; |
||
39 | |||
40 | /** |
||
41 | * Constructor |
||
42 | */ |
||
43 | 9 | public function __construct() |
|
57 | |||
58 | /** |
||
59 | * Register decoder for JSON API resource |
||
60 | * |
||
61 | * @param string $resType |
||
62 | * @param string|\Closure $decoder |
||
63 | * @return DecodersFactory |
||
64 | */ |
||
65 | 2 | public function registerResourceDecoder($resType, $decoder) |
|
69 | |||
70 | /** |
||
71 | * Register decoder for JSON API document |
||
72 | * |
||
73 | * @param $docType |
||
74 | * @param $decoder |
||
75 | * @return DecodersFactory |
||
76 | */ |
||
77 | 2 | public function registerDocumentDecoder($docType, $decoder) |
|
81 | |||
82 | /** |
||
83 | * Register decoder for JSON API request query parameter |
||
84 | * |
||
85 | * @param string $queryType |
||
86 | * @param string|\Closure $decoder |
||
87 | * @return DecodersFactory |
||
88 | */ |
||
89 | 2 | public function registerQueryParamsDecoder($queryType, $decoder) |
|
93 | |||
94 | /** |
||
95 | * @inheritdoc |
||
96 | */ |
||
97 | 3 | public function getResourceDecoder($type) |
|
101 | |||
102 | /** |
||
103 | * @inheritdoc |
||
104 | */ |
||
105 | 3 | public function getDocumentDecoder($type) |
|
109 | |||
110 | /** |
||
111 | * @inheritdoc |
||
112 | */ |
||
113 | 3 | public function getQueryParamsDecoder($type) |
|
117 | |||
118 | /** |
||
119 | * Register decoder in specified category |
||
120 | * |
||
121 | * @param string $category |
||
122 | * @param string $resType |
||
123 | * @param string|\Closure $decoder |
||
124 | * @return $this |
||
125 | */ |
||
126 | 6 | private function registerDecoderByCategory($category, $resType, $decoder) |
|
136 | |||
137 | /** |
||
138 | * Returns decoder instance for specified type from specified category |
||
139 | * |
||
140 | * @param string $category |
||
141 | * @param string $type |
||
142 | * @return mixed |
||
143 | */ |
||
144 | 9 | private function getDecoderInstanceByCategory($category, $type) |
|
156 | |||
157 | /** |
||
158 | * Create decoder instance |
||
159 | * |
||
160 | * @param string $category |
||
161 | * @param string|\Closure $decoder |
||
162 | * @return mixed |
||
163 | */ |
||
164 | 6 | private function createDecoder($category, $decoder) |
|
187 | } |