1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Lenevor Framework |
5
|
|
|
* |
6
|
|
|
* LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the new BSD license that is bundled |
9
|
|
|
* with this package in the file LICENSE. |
10
|
|
|
* It is also available through the world-wide-web at this URL: |
11
|
|
|
* https://lenevor.com/license |
12
|
|
|
* If you did not receive a copy of the license and are unable to |
13
|
|
|
* obtain it through the world-wide-web, please send an email |
14
|
|
|
* to [email protected] so we can send you a copy immediately. |
15
|
|
|
* |
16
|
|
|
* @package Lenevor |
17
|
|
|
* @subpackage Base |
18
|
|
|
* @link https://lenevor.com |
19
|
|
|
* @copyright Copyright (c) 2019 - 2021 Alexander Campo <[email protected]> |
20
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /LICENSE |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace Syscodes\Dotenv\Repository\Adapters; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Write and delete an environment variable. |
27
|
|
|
* |
28
|
|
|
* @author Alexander Campo <[email protected]> |
29
|
|
|
*/ |
30
|
|
|
final class Writers |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* The set of writers to use. |
34
|
|
|
* |
35
|
|
|
* @var \Syscodes\Dotenv\Repository\Adapters\Writers $writers |
36
|
|
|
*/ |
37
|
|
|
protected $writers; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Constructor. Create a new Writers instance. |
41
|
|
|
* |
42
|
|
|
* @param \Syscodes\Dotenv\Repository\Adapters\Writers $writers |
43
|
|
|
* |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
public function __construct(array $writers) |
47
|
|
|
{ |
48
|
|
|
$this->writers = $writers; |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Write to an environment variable. |
53
|
|
|
* |
54
|
|
|
* @param string $name |
55
|
|
|
* @param string $value |
56
|
|
|
* |
57
|
|
|
* @return bool |
58
|
|
|
*/ |
59
|
|
|
public function write(string $name, string $value) |
60
|
|
|
{ |
61
|
|
|
foreach ($this->writers as $writes) { |
62
|
|
|
if ( ! $writes->write($name, $value)) { |
63
|
|
|
return false; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return true; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Write to an environment variable. |
72
|
|
|
* |
73
|
|
|
* @param string $name |
74
|
|
|
* |
75
|
|
|
* @return bool |
76
|
|
|
*/ |
77
|
|
|
public function delete(string $name) |
78
|
|
|
{ |
79
|
|
|
foreach ($this->writers as $writes) { |
80
|
|
|
if ( ! $writes->delete($name)) { |
81
|
|
|
return false; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
return true; |
86
|
|
|
} |
87
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..