guardUnusableFile($filepath); $filepath = realpath($filepath); $this->info = new SplFileInfo($filepath); } public static function fromString(string $filepath): self { return new self($filepath); } public function getInfo(): SplFileInfo { return $this->info; } public function __toString(): string { return (string)$this->getInfo(); } private function guardUnusableFile(string $file): void { if (!file_exists($file)) { throw new FileNotFoundException($file); } if (!is_readable($file)) { throw new FileNotReadableException($file); } } }