url = $url; if ($anchor !== null) { $this->anchor = $anchor; } } /** * Get the url * * @return string */ public function getUrl(): string { return $this->url; } /** * Get the anchor * * @return string|null */ public function getAnchor(): ?string { return $this->anchor; } /** * Used for json_encode function * This can seem useless, do not remove it. * * @return array */ public function jsonSerialize(): array { $outObj = array(); $outObj['url'] = $this->url; if ($this->anchor !== null) { $outObj['anchor'] = $this->anchor; } return $outObj; } }