filename = $filename; return $this; } public function getFilename(): string { return $this->filename; } public function isDir(): bool { return is_dir($this->getFilename()); } public function isReadable(): bool { return is_readable($this->getFilename()); } public function isWriteable(): bool { return is_writeable($this->getFilename()); } public function read(?int $length = null): string { $fh = fopen($this->getFilename(), 'r'); $str = fgets($fh, $length); fclose($fh); return $str; } public function write(string $data, ?int $length = null): void { $fh = fopen($this->getFilename(), 'r'); fwrite($fh, $data, $length); fclose($fh); } }