From 110dc2831488937c1afb70c11657a341912fc8cd Mon Sep 17 00:00:00 2001 From: Peter Nguyen Date: Wed, 5 Feb 2025 00:44:12 -0600 Subject: Initial commit 2/25/2025 --- vendor/vlucas/phpdotenv/src/Store/File/Reader.php | 81 +++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 vendor/vlucas/phpdotenv/src/Store/File/Reader.php (limited to 'vendor/vlucas/phpdotenv/src/Store/File/Reader.php') diff --git a/vendor/vlucas/phpdotenv/src/Store/File/Reader.php b/vendor/vlucas/phpdotenv/src/Store/File/Reader.php new file mode 100644 index 0000000..b0b7c5b --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Store/File/Reader.php @@ -0,0 +1,81 @@ + + */ + public static function read(array $filePaths, bool $shortCircuit = true, ?string $fileEncoding = null) + { + $output = []; + + foreach ($filePaths as $filePath) { + $content = self::readFromFile($filePath, $fileEncoding); + if ($content->isDefined()) { + $output[$filePath] = $content->get(); + if ($shortCircuit) { + break; + } + } + } + + return $output; + } + + /** + * Read the given file. + * + * @param string $path + * @param string|null $encoding + * + * @throws \Dotenv\Exception\InvalidEncodingException + * + * @return \PhpOption\Option + */ + private static function readFromFile(string $path, ?string $encoding = null) + { + /** @var Option */ + $content = Option::fromValue(@\file_get_contents($path), false); + + return $content->flatMap(static function (string $content) use ($encoding) { + return Str::utf8($content, $encoding)->mapError(static function (string $error) { + throw new InvalidEncodingException($error); + })->success(); + }); + } +} -- cgit v1.2.3