You are here

protected static function HttpHeader::parseHeaderValue in RESTful 7.2

Parses the values and extras from a header value string.

Parameters

string $value:

Return value

array The $extras and $values.

2 calls to HttpHeader::parseHeaderValue()
HttpHeader::append in src/Http/HttpHeader.php
Appends a value into a header.
HttpHeader::create in src/Http/HttpHeader.php
Creates a header object from the key and value strings.

File

src/Http/HttpHeader.php, line 131
Contains \Drupal\restful\Http\HttpHeader

Class

HttpHeader

Namespace

Drupal\restful\Http

Code

protected static function parseHeaderValue($value) {
  $extras = NULL;
  $parts = explode(';', $value);
  if (count($parts) > 1) {

    // Only consider the last element.
    $extras = array_pop($parts);
    $extras = trim($extras);

    // In case there were more than one ';' then put everything back.
    $value = implode(';', $parts);
  }
  $values = array_map('trim', explode(',', $value));
  return array(
    $extras,
    $values,
  );
}