From de8be0fe1b76bcfe364ba1b9381c1fd6ea0e0dd9 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Wed, 17 May 2023 17:57:08 -0400 Subject: [PATCH 1/2] reformat: Initializer --- src/PlainText/PrivateJson.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) ); From 92eadb88e7f5c9d489b03426b48ef0e022a12621 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Wed, 17 May 2023 17:57:23 -0400 Subject: [PATCH 2/2] create: PrivateFile - same as PrivateJson --- src/PlainText/PrivateFile.php | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/PlainText/PrivateFile.php 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(); + } +}