@@ -33,22 +33,22 @@ discard block |
||
| 33 | 33 | $this->parse(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Retrieves an indexed array with accept mime types |
|
| 38 | - * that the client sent, in the order of preference |
|
| 39 | - * the client specified. |
|
| 40 | - * |
|
| 41 | - * Example: |
|
| 42 | - * |
|
| 43 | - * array( |
|
| 44 | - * 'text/html', |
|
| 45 | - * 'application/xhtml+xml', |
|
| 46 | - * 'image/webp' |
|
| 47 | - * ... |
|
| 48 | - * ) |
|
| 49 | - * |
|
| 50 | - * @return string[] |
|
| 51 | - */ |
|
| 36 | + /** |
|
| 37 | + * Retrieves an indexed array with accept mime types |
|
| 38 | + * that the client sent, in the order of preference |
|
| 39 | + * the client specified. |
|
| 40 | + * |
|
| 41 | + * Example: |
|
| 42 | + * |
|
| 43 | + * array( |
|
| 44 | + * 'text/html', |
|
| 45 | + * 'application/xhtml+xml', |
|
| 46 | + * 'image/webp' |
|
| 47 | + * ... |
|
| 48 | + * ) |
|
| 49 | + * |
|
| 50 | + * @return string[] |
|
| 51 | + */ |
|
| 52 | 52 | public function getMimeStrings() : array |
| 53 | 53 | { |
| 54 | 54 | $result = array(); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | return $result; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Checks that an "Accept" header string exists, and tries to parse it. |
|
| 66 | - */ |
|
| 64 | + /** |
|
| 65 | + * Checks that an "Accept" header string exists, and tries to parse it. |
|
| 66 | + */ |
|
| 67 | 67 | protected function parse() : void |
| 68 | 68 | { |
| 69 | 69 | // we may be in a CLI environment where the headers |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | $this->headers = $this->parseHeader($_SERVER['HTTP_ACCEPT']); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Splits the "Accept" header string and parses the mime types. |
|
| 80 | - * |
|
| 81 | - * @param string $acceptHeader |
|
| 82 | - * @return AcceptHeader[] |
|
| 83 | - */ |
|
| 78 | + /** |
|
| 79 | + * Splits the "Accept" header string and parses the mime types. |
|
| 80 | + * |
|
| 81 | + * @param string $acceptHeader |
|
| 82 | + * @return AcceptHeader[] |
|
| 83 | + */ |
|
| 84 | 84 | protected function parseHeader(string $acceptHeader) : array |
| 85 | 85 | { |
| 86 | 86 | $tokens = preg_split('/\s*,\s*/', $acceptHeader); |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | return $accept; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Parses a single mime type entry. |
|
| 102 | - * |
|
| 103 | - * @param int $i The position in the "Accept" string |
|
| 104 | - * @param string $mime The mime type |
|
| 105 | - * @return AcceptHeader |
|
| 106 | - */ |
|
| 100 | + /** |
|
| 101 | + * Parses a single mime type entry. |
|
| 102 | + * |
|
| 103 | + * @param int $i The position in the "Accept" string |
|
| 104 | + * @param string $mime The mime type |
|
| 105 | + * @return AcceptHeader |
|
| 106 | + */ |
|
| 107 | 107 | protected function parseEntry(int $i, string $mime) : AcceptHeader |
| 108 | 108 | { |
| 109 | 109 | $quality = 0; |
@@ -148,14 +148,12 @@ |
||
| 148 | 148 | if ($diff > 0) |
| 149 | 149 | { |
| 150 | 150 | $diff = 1; |
| 151 | - } |
|
| 152 | - else |
|
| 151 | + } else |
|
| 153 | 152 | { |
| 154 | 153 | if ($diff < 0) |
| 155 | 154 | { |
| 156 | 155 | $diff = -1; |
| 157 | - } |
|
| 158 | - else |
|
| 156 | + } else |
|
| 159 | 157 | { |
| 160 | 158 | /* tie-breaker: first listed item wins */ |
| 161 | 159 | $diff = $a->getPosition() - $b->getPosition(); |