1 | <?php |
||
15 | final class ContentTypePlugin implements Plugin |
||
16 | { |
||
17 | /** |
||
18 | * Allow to disable the content type detection when stream is too large (as it can consume a lot of resource). |
||
19 | * |
||
20 | * @var bool |
||
21 | * |
||
22 | * true skip the content type detection |
||
23 | * false detect the content type (default value) |
||
24 | */ |
||
25 | protected $skipDetection; |
||
26 | |||
27 | /** |
||
28 | * Determine the size stream limit for which the detection as to be skipped (default to 16Mb). |
||
29 | * |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $sizeLimit; |
||
33 | |||
34 | /** |
||
35 | * @param array $config { |
||
36 | * |
||
37 | * @var bool $skip_detection True skip detection if stream size is bigger than $size_limit. |
||
38 | * @var int $size_limit size stream limit for which the detection as to be skipped. |
||
39 | * } |
||
40 | */ |
||
41 | 10 | public function __construct(array $config = []) |
|
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 8 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
93 | |||
94 | /** |
||
95 | * @param $stream StreamInterface |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | 5 | private function isJson($stream) |
|
107 | |||
108 | /** |
||
109 | * @param $stream StreamInterface |
||
110 | * |
||
111 | * @return \SimpleXMLElement|false |
||
112 | */ |
||
113 | 4 | private function isXml($stream) |
|
123 | } |
||
124 |