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
final class MultiWriter implements WriterInterface
8
{
9
    /**
10
     * The set of writers to use.
11
     *
12
     * @var \Dotenv\Repository\Adapter\WriterInterface[]
13
     */
14
    private $writers;
15
 
16
    /**
17
     * Create a new multi-writer instance.
18
     *
19
     * @param \Dotenv\Repository\Adapter\WriterInterface[] $writers
20
     *
21
     * @return void
22
     */
23
    public function __construct(array $writers)
24
    {
25
        $this->writers = $writers;
26
    }
27
 
28
    /**
29
     * Write to an environment variable, if possible.
30
     *
31
     * @param non-empty-string $name
32
     * @param string           $value
33
     *
34
     * @return bool
35
     */
36
    public function write(string $name, string $value)
37
    {
38
        foreach ($this->writers as $writers) {
39
            if (!$writers->write($name, $value)) {
40
                return false;
41
            }
42
        }
43
 
44
        return true;
45
    }
46
 
47
    /**
48
     * Delete an environment variable, if possible.
49
     *
50
     * @param non-empty-string $name
51
     *
52
     * @return bool
53
     */
54
    public function delete(string $name)
55
    {
56
        foreach ($this->writers as $writers) {
57
            if (!$writers->delete($name)) {
58
                return false;
59
            }
60
        }
61
 
62
        return true;
63
    }
64
}