getHeaderAndFlags($id); $this->rawHeader = $data['header']; $this->flagList = $data['flags']; } $this->id = $id; $this->storage = $storage; $this->parser = $parser; } public function setFullRawContent(string $content): void { $this->fullRawContent = $content; } public function getRawHeader(): string { return $this->rawHeader ?? ''; } public function getParser(): ?Parser { return $this->parser; } public function hasAttribute(string $attribute): bool { return $this->getParser()->hasMessageAttribute($this, $attribute); } public function getAttribute(string $attribute): ?string { return $this->getParser()->getMessageAttribute($this, $attribute); } public function getRawContent(): string { if (is_null($this->rawContent)) { $this->rawContent = $this->storage->getRawContent((int) $this->id); } return $this->rawContent ?? ''; } public function getFullRawContent(): string { if ($this->fullRawContent) { return $this->fullRawContent; } return $this->getRawHeader() . "\n" . $this->getRawContent(); } public function getMessage(): Message { if (!$this->message) { $data = []; if ($this->storage) { $data['handler'] = $this->storage; } if ($this->flagList) { $data['flags'] = $this->flagList; } if ($this->fullRawContent) { $data['raw'] = $this->fullRawContent; } else if ($this->rawHeader) { $data['headers'] = $this->rawHeader; } if ($this->id) { $data['id'] = $this->id; } $this->message = new Message($data); } return $this->message; } public function getFlags(): array { return $this->flagList ?? []; } public function isFetched(): bool { return (bool) $this->rawHeader; } }