version = $version; $this->description = $description; } public static function create( ?string $body, ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null ): ?self { if (empty($body)) { return new static(); } $matches = []; if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { return null; } $description = null; if ($descriptionFactory !== null) { $description = $descriptionFactory->create($matches[2] ?? '', $context); } return new static( $matches[1], $description ); } /** * Gets the version section of the tag. */ public function getVersion(): ?string { return $this->version; } /** * Returns a string representation for this tag. */ public function __toString(): string { if ($this->description) { $description = $this->description->render(); } else { $description = ''; } $version = (string) $this->version; return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : ''); } }