path = $relativeTo ? $relativeTo->parent()->asString() . '/' . StringUtils::removeFromStart(trim($path), './') : trim($path); } public function asString(): string { return $this->path; } public function exists(): bool { clearstatcache(); return file_exists($this->path); } public function parent(): Directory { return new Directory(dirname($this->path)); } public function mkdir($mode = 0777) { $parent = $this->parent(); if (mkdir($parent->asString(), $mode, true) === false) { throw new \RuntimeException("Could not create directory '{$parent->asString()}'!"); } } }