Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added process of booleans #1

Merged
merged 3 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Branch refactor
  • Loading branch information
jaumarar committed Feb 13, 2021
commit df89dde4aeda2ae3b4e79b42ec864d81428823db
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use DevCoder\DotEnv;

echo getenv('APP_ENV');
// dev
echo getenv('DATABASE_DNS')
echo getenv('DATABASE_DNS');
// mysql:host=localhost;dbname=test;
```
Ideal for small project
Expand Down
10 changes: 3 additions & 7 deletions src/DotEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(string $path, array $options = [])
$this->processOptions($options);
}

private function processOptions(array $options)
private function processOptions(array $options) : void
{
$this->options = array_merge([
static::PROCESS_BOOLEANS => true
Expand All @@ -52,10 +52,8 @@ private function processOptions(array $options)
/**
* Processes the $path of the instances and parses the values into $_SERVER and $_ENV, also returns all the data that has been read.
* Skips empty and commented lines.
*
* @return array The values that have been loaded into ENV
*/
public function load() :array
public function load() : void
{
if (!is_readable($this->path)) {
throw new \RuntimeException(sprintf('%s file is not readable', $this->path));
Expand All @@ -81,11 +79,9 @@ public function load() :array
$loaded[$name] = $value;
}
}

return $loaded;
}

private function processValue($value) {
private function processValue(string $value) {
$trimmedValue = trim($value);

if (!empty($this->options[static::PROCESS_BOOLEANS])) {
Expand Down