Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace Dotenv\Repository\Adapter;
6
 
7
use PhpOption\None;
8
 
9
final class MultiReader implements ReaderInterface
10
{
11
    /**
12
     * The set of readers to use.
13
     *
14
     * @var \Dotenv\Repository\Adapter\ReaderInterface[]
15
     */
16
    private $readers;
17
 
18
    /**
19
     * Create a new multi-reader instance.
20
     *
21
     * @param \Dotenv\Repository\Adapter\ReaderInterface[] $readers
22
     *
23
     * @return void
24
     */
25
    public function __construct(array $readers)
26
    {
27
        $this->readers = $readers;
28
    }
29
 
30
    /**
31
     * Read an environment variable, if it exists.
32
     *
33
     * @param non-empty-string $name
34
     *
35
     * @return \PhpOption\Option<string>
36
     */
37
    public function read(string $name)
38
    {
39
        foreach ($this->readers as $reader) {
40
            $result = $reader->read($name);
41
            if ($result->isDefined()) {
42
                return $result;
43
            }
44
        }
45
 
46
        return None::create();
47
    }
48
}