You are here

public static function AcceptHeader::fromString in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/AcceptHeader.php \Symfony\Component\HttpFoundation\AcceptHeader::fromString()

Builds an AcceptHeader instance from a string.

Parameters

string $headerValue:

Return value

AcceptHeader

3 calls to AcceptHeader::fromString()
AcceptHeaderTest::testFirst in vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php
AcceptHeaderTest::testFromString in vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php
@dataProvider provideFromStringData
AcceptHeaderTest::testSorting in vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php
@dataProvider provideSortingData

File

vendor/symfony/http-foundation/AcceptHeader.php, line 53

Class

AcceptHeader
Represents an Accept-* header.

Namespace

Symfony\Component\HttpFoundation

Code

public static function fromString($headerValue) {
  $index = 0;
  return new self(array_map(function ($itemValue) use (&$index) {
    $item = AcceptHeaderItem::fromString($itemValue);
    $item
      ->setIndex($index++);
    return $item;
  }, preg_split('/\\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\\s*/', $headerValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)));
}