refers = $refers; $this->description = $description; } public static function create( string $body, ?FqsenResolver $typeResolver = null, ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null ) : self { Assert::notNull($typeResolver); Assert::notNull($descriptionFactory); $parts = preg_split('/\s+/Su', $body, 2); Assert::isArray($parts); $description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null; // https://tools.ietf.org/html/rfc2396#section-3 if (preg_match('/\w:\/\/\w/i', $parts[0])) { return new static(new Url($parts[0]), $description); } return new static(new FqsenRef($typeResolver->resolve($parts[0], $context)), $description); } /** * Returns the ref of this tag. */ public function getReference() : Reference { return $this->refers; } /** * Returns a string representation of this tag. */ public function __toString() : string { return $this->refers . ($this->description ? ' ' . $this->description->render() : ''); } }