コード例 #1
0
ファイル: AcceptHeader.php プロジェクト: saj696/pipe
 /**
  * Builds an AcceptHeader instance from a string.
  *
  * @param string $headerValue
  *
  * @return AcceptHeader
  */
 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)));
 }
コード例 #2
0
ファイル: AcceptHeader.php プロジェクト: noelg/symfony
 /**
  * Adds an item.
  *
  * @param AcceptHeaderItem $item
  *
  * @return AcceptHeader
  */
 public function add(AcceptHeaderItem $item)
 {
     $this->items[$item->getValue()] = $item;
     $this->sorted = false;
     return $this;
 }