1 | <?php |
||
5 | class ContentType extends Common |
||
6 | { |
||
7 | |||
8 | protected $headerName = 'Content-Type'; |
||
9 | |||
10 | |||
11 | /** |
||
12 | * @param string $headerValue |
||
13 | * @return array |
||
14 | */ |
||
15 | 8 | protected function extractData($headerValue) |
|
16 | { |
||
17 | 8 | $result = []; |
|
18 | 8 | $parts = preg_split('#;\s?#', $headerValue, -1, \PREG_SPLIT_NO_EMPTY); |
|
19 | |||
20 | 8 | if (count($parts) === 0) { |
|
21 | 1 | return []; |
|
22 | } |
||
23 | |||
24 | 7 | $result['value'] = array_shift($parts); |
|
25 | |||
26 | 7 | foreach ($parts as $item) { |
|
27 | 4 | list($key, $value) = explode('=', $item . '='); |
|
28 | 4 | $result[ $key ] = $value; |
|
29 | } |
||
30 | |||
31 | 7 | return $result; |
|
32 | } |
||
33 | |||
34 | |||
35 | /** |
||
36 | * @param string $type |
||
37 | * @return bool |
||
38 | */ |
||
39 | 3 | public function contains($type) |
|
43 | |||
44 | |||
45 | 5 | public function match($type) |
|
53 | |||
54 | |||
55 | 4 | private function isCompatible($target, $pattern) |
|
59 | |||
60 | |||
61 | /** |
||
62 | * @param string $target |
||
63 | * @param string $pattern |
||
64 | * @return string |
||
65 | */ |
||
66 | 4 | private function replaceStars($target, $pattern) |
|
81 | } |
||
82 |