You are here

public function HttpHeaderBag::get in RESTful 7.2

Get the the header object for a header name or ID.

Parameters

string $key: The header ID or header name.

Return value

HttpHeaderInterface The header object.

Overrides HttpHeaderBagInterface::get

1 call to HttpHeaderBag::get()
HttpHeaderBag::append in src/Http/HttpHeaderBag.php
Appends the values of the passed in header to if the header already exists.

File

src/Http/HttpHeaderBag.php, line 50
Contains \Drupal\restful\Http\HttpHeaderBag.

Class

HttpHeaderBag

Namespace

Drupal\restful\Http

Code

public function get($key) {

  // Assume that $key is an ID.
  if (array_key_exists($key, $this->values)) {
    return $this->values[$key];
  }

  // Test if key was a header name.
  $key = HttpHeader::generateId($key);
  if (array_key_exists($key, $this->values)) {
    return $this->values[$key];
  }

  // Return a NULL object on which you can still call the HttpHeaderInterface
  // methods.
  return HttpHeaderNull::create(NULL, NULL);
}