Skip to content

Commit

Permalink
Fix rename method envVariableExists to envVariableExistsInMemory
Browse files Browse the repository at this point in the history
  • Loading branch information
prinx committed Aug 18, 2020
1 parent c72257c commit 0488518
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public function get($name = '', $default = null)

$lastIndex = count($nameExploded) - 1;
foreach ($nameExploded as $key => $variableName) {
if (! $variableName) {
if (!$variableName) {
return null;
}

if (isset($lookup[$variableName])) {
if (! is_array($value) && $key < $lastIndex) {
if (!is_array($value) && $key < $lastIndex) {
return null;
}

Expand Down Expand Up @@ -140,11 +140,11 @@ public function persist($name, $value, $overwrite = true, $quoteString = true)
$content = preg_replace($pattern, $line, $content);
} elseif (
($envVariableExistsInMemory && $overwrite) ||
! $envVariableExistsInMemory ||
! $envVariableExistsInFile
!$envVariableExistsInMemory ||
!$envVariableExistsInFile
) {
$content = trim($content)."\n\n".$line;
} elseif (($envVariableExistsInMemory || $envVariableExistsInFile) && ! $overwrite) {
} elseif (($envVariableExistsInMemory || $envVariableExistsInFile) && !$overwrite) {
return;
}

Expand All @@ -171,7 +171,7 @@ protected function replaceReferences()
if (preg_match($pattern, $line, $matches)) {
$ref = $matches[3];

if (! $this->envVariableExists($ref)) {
if (!$this->envVariableExistsInMemory($ref)) {
return null;
}

Expand Down Expand Up @@ -232,9 +232,9 @@ protected function valueSameAsReference($refValue, $lineValue)
protected function isStringifiable($var)
{
return
! is_array($var) &&
((! is_object($var) && settype($var, 'string') !== false) ||
(is_object($var) && method_exists($var, '__toString')));
!is_array($var) &&
((!is_object($var) && settype($var, 'string') !== false) ||
(is_object($var) && method_exists($var, '__toString')));
}

/**
Expand Down Expand Up @@ -275,10 +275,6 @@ protected function envVariableExistsInMemory($name)
return isset($this->env[$name]) || (bool) getenv($name);
}

public function variableExistsInEnvFile($name)
{
}

/**
* Get the line number of a string, in a file.
*
Expand Down Expand Up @@ -309,14 +305,14 @@ protected function getLineWithString($fileName, $str)
*/
protected function addIfNotExists($name, $value, $section = '')
{
if (! isset($this->env[$name])) {
if (!isset($this->env[$name])) {
$this->add($name, $value, $section);
}
}

public function setPath($path)
{
if (! \file_exists($path)) {
if (!\file_exists($path)) {
throw new \Exception('Trying to set the env file path but the file '.$path.' seems not to exist.');
}

Expand Down

0 comments on commit 0488518

Please sign in to comment.