raw = $value; $this->type = $type; $publicPath = Environment::getPublicPath(); if ($type === self::TYPE_RELATIVE) { $this->relative = $value; $this->absolute = PathUtility::getCanonicalPath($publicPath . $value) . '/'; } elseif ($type === self::TYPE_ABSOLUTE) { $this->absolute = $value; $this->relative = str_starts_with($value, $publicPath) ? substr($value, strlen($publicPath)) : null; } } /** * @return string normalized path as provided */ public function getRaw(): string { return $this->raw; } /** * @return string|null (calculated) relative path to public path - `null` if outside public path */ public function getRelative(): ?string { return $this->relative; } /** * @return string (calculated) absolute path */ public function getAbsolute(): string { return $this->absolute; } public function isAbsolute(): bool { return $this->type === self::TYPE_ABSOLUTE; } public function isRelative(): bool { return $this->type === self::TYPE_RELATIVE; } }