Skip to content

Commit c3f0244

Browse files
Merge pull request #183 from xxnoobmanxx/patch-1
Avoid code duplication
2 parents c15a945 + b2712cc commit c3f0244

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Dotenv.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public function __construct($path, $file = '.env')
4545
*/
4646
public function load()
4747
{
48-
$this->loader = new Loader($this->filePath, true);
49-
50-
return $this->loader->load();
48+
return $this->getLoaderData();
5149
}
5250

5351
/**
@@ -57,9 +55,7 @@ public function load()
5755
*/
5856
public function overload()
5957
{
60-
$this->loader = new Loader($this->filePath, false);
61-
62-
return $this->loader->load();
58+
return $this->getLoaderData(true);
6359
}
6460

6561
/**
@@ -80,6 +76,16 @@ protected function getFilePath($path, $file)
8076

8177
return $filePath;
8278
}
79+
80+
/**
81+
* Load data from '.env'
82+
* @return array
83+
*/
84+
private function getLoaderData($overload = false)
85+
{
86+
$this->loader = new Loader($this->filePath, !$overload);
87+
return $this->loader->load();
88+
}
8389

8490
/**
8591
* Required ensures that the specified variables exist, and returns a new Validator object.

0 commit comments

Comments
 (0)