Skip to content

Commit

Permalink
Fix empty string value same as null
Browse files Browse the repository at this point in the history
  • Loading branch information
prinx committed Jul 29, 2020
1 parent 89508da commit 64fc02d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ public function get($name = '', $default = null)
return $this->all();
}

$defaultWasPassed = \func_num_args() === 2;

if (isset($this->env[$name])) {
if ('' === $this->env[$name]) {
return $defaultWasPassed ? $default : '';
}

return $this->env[$name];
} elseif ($value = getenv($name)) {
return $value;
Expand All @@ -159,7 +165,7 @@ public function get($name = '', $default = null)

$lookup = $value;
} else {
return \func_num_args() < 2 ? getenv($variable_name) : $default;
return $defaultWasPassed ? $default : getenv($variable_name);
}
}

Expand Down

0 comments on commit 64fc02d

Please sign in to comment.