version = $version; $this->description = $description; } /** * @return static */ 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 new static( null, $descriptionFactory !== null ? $descriptionFactory->create($body, $context) : null ); } Assert::notNull($descriptionFactory); return new static( $matches[1], $descriptionFactory->create($matches[2] ?? '', $context) ); } /** * 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 : ''); } }