File tree Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -86,9 +86,7 @@ protected function getFilePath($path, $file)
86
86
*/
87
87
protected function loadData ($ overload = false )
88
88
{
89
- $ this ->loader = new Loader ($ this ->filePath , !$ overload );
90
-
91
- return $ this ->loader ->load ();
89
+ return $ this ->loader ->setImmutable (!$ overload )->load ();
92
90
}
93
91
94
92
/**
Original file line number Diff line number Diff line change @@ -42,6 +42,29 @@ public function __construct($filePath, $immutable = false)
42
42
$ this ->immutable = $ immutable ;
43
43
}
44
44
45
+ /**
46
+ * Set immutable value.
47
+ *
48
+ * @param bool $immutable
49
+ * @return $this
50
+ */
51
+ public function setImmutable ($ immutable = false )
52
+ {
53
+ $ this ->immutable = $ immutable ;
54
+
55
+ return $ this ;
56
+ }
57
+
58
+ /**
59
+ * Set immutable value.
60
+ *
61
+ * @return bool
62
+ */
63
+ public function getImmutable ()
64
+ {
65
+ return $ this ->immutable ;
66
+ }
67
+
45
68
/**
46
69
* Load `.env` file in given directory.
47
70
*
Original file line number Diff line number Diff line change @@ -74,6 +74,17 @@ protected function value()
74
74
return reset ($ keyVal );
75
75
}
76
76
77
+ public function testMutableLoaderSetUnsetImmutable ()
78
+ {
79
+ $ immutable = $ this ->mutableLoader ->getImmutable ();
80
+
81
+ // Set Immutable.
82
+ $ this ->mutableLoader ->setImmutable (!$ immutable );
83
+ $ this ->assertSame (!$ immutable , $ this ->mutableLoader ->getImmutable ());
84
+ $ this ->mutableLoader ->setImmutable ($ immutable );
85
+ $ this ->assertSame ($ immutable , $ this ->mutableLoader ->getImmutable ());
86
+ }
87
+
77
88
public function testMutableLoaderClearsEnvironmentVars ()
78
89
{
79
90
// Set an environment variable.
@@ -87,6 +98,17 @@ public function testMutableLoaderClearsEnvironmentVars()
87
98
$ this ->assertSame (false , isset ($ _SERVER [$ this ->key ()]));
88
99
}
89
100
101
+ public function testImmutableLoaderSetUnsetImmutable ()
102
+ {
103
+ $ immutable = $ this ->immutableLoader ->getImmutable ();
104
+
105
+ // Set Immutable.
106
+ $ this ->immutableLoader ->setImmutable (!$ immutable );
107
+ $ this ->assertSame (!$ immutable , $ this ->immutableLoader ->getImmutable ());
108
+ $ this ->immutableLoader ->setImmutable ($ immutable );
109
+ $ this ->assertSame ($ immutable , $ this ->immutableLoader ->getImmutable ());
110
+ }
111
+
90
112
public function testImmutableLoaderCannotClearEnvironmentVars ()
91
113
{
92
114
// Set an environment variable.
You can’t perform that action at this time.
0 commit comments