name = $name; $this->rawValue = $value; $consumer = $this->getConsumer($consumerService); $this->setParseHeaderValue($consumer); } /** * Returns the header's Consumer * * @return AbstractConsumer */ abstract protected function getConsumer(ConsumerService $consumerService); /** * Calls the consumer and assigns the parsed parts to member variables. * * The default implementation assigns the returned value to $this->part. * * @return static */ protected function setParseHeaderValue(AbstractConsumer $consumer) { $this->parts = $consumer($this->rawValue); return $this; } /** * @return IHeaderPart[] */ public function getParts() : array { return $this->parts; } public function getValue() : ?string { if (!empty($this->parts)) { return $this->parts[0]->getValue(); } return null; } public function getRawValue() : string { return $this->rawValue; } public function getName() : string { return $this->name; } public function __toString() : string { return "{$this->name}: {$this->rawValue}"; } }