Skip to content

Commit

Permalink
Be explicit about differences with PSR-7
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Feb 9, 2017
1 parent 490775b commit 54f46bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ See the above usage example and the class outline for details.
#### getHeaders()

The `getHeaders(): array` method can be used to
return ALL headers.
return an array with ALL headers.

This will return an (possibly empty) assoc array with header names as
key and header values as value. The header value will be a string if
there's only a single value or an array of strings if this header has
multiple values.
The keys represent the header name in the exact case in which they were
originally specified. The values will be a string if there's only a single
value for the respective header name or an array of strings if this header
has multiple values.

Note that this differs from the PSR-7 implementation of this method.
> Note that this differs from the PSR-7 implementation of this method,
which always returns an array for each header name, even if it only has a
single value.

#### getHeader()

Expand Down
16 changes: 9 additions & 7 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ public function getHttpVersion()
}

/**
* Returns ALL headers
* Returns an array with ALL headers
*
* This will return an (possibly empty) assoc array with header names as
* key and header values as value. The header value will be a string if
* there's only a single value or an array of strings if this header has
* multiple values.
* The keys represent the header name in the exact case in which they were
* originally specified. The values will be a string if there's only a single
* value for the respective header name or an array of strings if this header
* has multiple values.
*
* Note that this differs from the PSR-7 implementation of this method.
* Note that this differs from the PSR-7 implementation of this method,
* which always returns an array for each header name, even if it only has a
* single value.
*
* @return array
*/
Expand All @@ -79,7 +81,7 @@ public function getHeader($name)
foreach ($this->headers as $key => $value) {
if (strtolower($key) === $name) {
foreach((array)$value as $one) {
$found []= $one;
$found[] = $one;
}
}
}
Expand Down

0 comments on commit 54f46bb

Please sign in to comment.