image = $image; $this->page = $page; } /** * @param WikiPath $image * @param MarkupPath $page * @return PageImage */ public static function create(WikiPath $image, ResourceCombo $page): PageImage { return new PageImage($image, $page); } /** * @param array $usages * @return $this * @throws ExceptionCompile */ public function setUsages(array $usages): PageImage { foreach ($usages as $usage) { $value = trim($usage); if ($value === "") { continue; } if (!in_array($value, PageImageUsage::getUsageValues())) { throw new ExceptionCompile("The page image usage value ($value) is not valid."); } $this->usages[$value] = $value; } return $this; } public function getImagePath(): WikiPath { return $this->image; } public function getUsages(): array { if ($this->usages === null) { return $this->getDefaultUsage(); } return array_values($this->usages); } public function getDefaultUsage(): array { return [PageImageUsage::DEFAULT]; } /** * @return MarkupPath */ public function getPage(): MarkupPath { return $this->page; } }