diff --git a/src/PlainText/PrivateFile.php b/src/PlainText/PrivateFile.php new file mode 100644 index 0000000..41b38a4 --- /dev/null +++ b/src/PlainText/PrivateFile.php @@ -0,0 +1,61 @@ +privateFile->notFound(); + } + + public function isFile(): bool + { + return $this->privateFile->isFile(); + } + + public function toBool(): bool + { + return $this->privateFile->toBool(); + } + + public function toString(): string + { + if ($this->notFound()) { + return ''; + } + + $content = file_get_contents($this->privateFile->toString()); + if ($content === false) { + return ''; + } + return $content; + } + + public function __toString(): string + { + return $this->toString(); + } +} diff --git a/src/PlainText/PrivateJson.php b/src/PlainText/PrivateJson.php index 0978049..9750a15 100644 --- a/src/PlainText/PrivateJson.php +++ b/src/PlainText/PrivateJson.php @@ -11,8 +11,11 @@ final class PrivateJson { - public static function inRoot(Root $root, string $filename, string $at = ''): self - { + public static function inRoot( + Root $root, + string $filename, + string $at = '' + ): self { return new self( PrivateFile::inRoot($root, $filename, $at) );