Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
- [Fixed] The method handle() does not exists. (Pull request #19, #23. Issue #18)
- [Fixed] The value "0" isn't displayed in output array. (Pull request #20)
- [Fixed] The error "Undefined property" in the class DotenvWriter. (Pull request #22)
  • Loading branch information
JackieDo committed Dec 10, 2018
1 parent d27e12b commit 646094f
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 127 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ php:
- 5.4
- 5.5
- 5.6
- hhvm

before_script:
- travis_retry composer self-update
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
syntaxCheck="true">
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
Expand Down
22 changes: 2 additions & 20 deletions src/Jackiedo/DotenvEditor/Console/Commands/DotenvBackupCommand.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php namespace Jackiedo\DotenvEditor\Console\Commands;

use Illuminate\Console\Command;
use Jackiedo\DotenvEditor\DotenvEditor;
use Jackiedo\DotenvEditor\Console\Traits\CreateCommandInstanceTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class DotenvBackupCommand extends Command
{
use CreateCommandInstanceTrait;

/**
* The console command name.
Expand All @@ -22,32 +23,13 @@ class DotenvBackupCommand extends Command
*/
protected $description = 'Backup the .env file';

/**
* The .env file editor instance
*
* @var \Jackiedo\DotenvEditor\DotenvEditor
*/
protected $editor;

/**
* The .env file path
*
* @var string|null
*/
protected $filePath = null;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(DotenvEditor $editor)
{
parent::__construct();

$this->editor = $editor;
}

/**
* Execute the console command.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Jackiedo\DotenvEditor\DotenvEditor;
use Jackiedo\DotenvEditor\Console\Traits\CreateCommandInstanceTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class DotenvDeleteKeyCommand extends Command
{
use ConfirmableTrait;
use ConfirmableTrait, CreateCommandInstanceTrait;

/**
* The console command name.
Expand All @@ -24,13 +24,6 @@ class DotenvDeleteKeyCommand extends Command
*/
protected $description = 'Delete one setter in the .env file';

/**
* The .env file editor instance
*
* @var \Jackiedo\DotenvEditor\DotenvEditor
*/
protected $editor;

/**
* The .env file path
*
Expand All @@ -45,18 +38,6 @@ class DotenvDeleteKeyCommand extends Command
*/
protected $key;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(DotenvEditor $editor)
{
parent::__construct();

$this->editor = $editor;
}

/**
* Execute the console command.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php namespace Jackiedo\DotenvEditor\Console\Commands;

use Illuminate\Console\Command;
use Jackiedo\DotenvEditor\DotenvEditor;
use Jackiedo\DotenvEditor\Console\Traits\CreateCommandInstanceTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class DotenvGetBackupsCommand extends Command
{
use CreateCommandInstanceTrait;

/**
* The console command name.
Expand All @@ -22,25 +23,6 @@ class DotenvGetBackupsCommand extends Command
*/
protected $description = 'List all the .env file backup versions';

/**
* The .env file editor instance
*
* @var \Jackiedo\DotenvEditor\DotenvEditor
*/
protected $editor;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(DotenvEditor $editor)
{
parent::__construct();

$this->editor = $editor;
}

/**
* Execute the console command.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php namespace Jackiedo\DotenvEditor\Console\Commands;

use Illuminate\Console\Command;
use Jackiedo\DotenvEditor\DotenvEditor;
use Jackiedo\DotenvEditor\Console\Traits\CreateCommandInstanceTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class DotenvGetKeysCommand extends Command
{
use CreateCommandInstanceTrait;

/**
* The console command name.
Expand All @@ -22,32 +23,13 @@ class DotenvGetKeysCommand extends Command
*/
protected $description = 'List all setter in the .env file';

/**
* The .env file editor instance
*
* @var \Jackiedo\DotenvEditor\DotenvEditor
*/
protected $editor;

/**
* The .env file path
*
* @var string|null
*/
protected $filePath = null;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(DotenvEditor $editor)
{
parent::__construct();

$this->editor = $editor;
}

/**
* Execute the console command.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Jackiedo\DotenvEditor\DotenvEditor;
use Jackiedo\DotenvEditor\Console\Traits\CreateCommandInstanceTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class DotenvRestoreCommand extends Command
{
use ConfirmableTrait;
use ConfirmableTrait, CreateCommandInstanceTrait;

/**
* The name and signature of the console command.
Expand All @@ -24,13 +24,6 @@ class DotenvRestoreCommand extends Command
*/
protected $description = 'Restore the .env file from backup or special file';

/**
* The .env file editor instance
*
* @var \Jackiedo\DotenvEditor\DotenvEditor
*/
protected $editor;

/**
* The .env file path
*
Expand All @@ -45,18 +38,6 @@ class DotenvRestoreCommand extends Command
*/
protected $retorePath = null;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(DotenvEditor $editor)
{
parent::__construct();

$this->editor = $editor;
}

/**
* Execute the console command.
*
Expand Down
23 changes: 2 additions & 21 deletions src/Jackiedo/DotenvEditor/Console/Commands/DotenvSetKeyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Jackiedo\DotenvEditor\DotenvEditor;
use Jackiedo\DotenvEditor\Console\Traits\CreateCommandInstanceTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class DotenvSetKeyCommand extends Command
{
use ConfirmableTrait;
use ConfirmableTrait, CreateCommandInstanceTrait;

/**
* The console command name.
Expand All @@ -24,13 +24,6 @@ class DotenvSetKeyCommand extends Command
*/
protected $description = 'Add new or update one setter into the .env file';

/**
* The .env file editor instance
*
* @var \Jackiedo\DotenvEditor\DotenvEditor
*/
protected $editor;

/**
* The .env file path
*
Expand Down Expand Up @@ -80,18 +73,6 @@ class DotenvSetKeyCommand extends Command
*/
protected $exportKey = false;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(DotenvEditor $editor)
{
parent::__construct();

$this->editor = $editor;
}

/**
* Execute the console command.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php namespace Jackiedo\DotenvEditor\Console\Traits;

use Jackiedo\DotenvEditor\DotenvEditor;

trait CreateCommandInstanceTrait
{
/**
* The .env file editor instance
*
* @var \Jackiedo\DotenvEditor\DotenvEditor
*/
protected $editor;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(DotenvEditor $editor)
{
parent::__construct();

$this->editor = $editor;
}

/**
* Execute the console command.
* This is alias of the method fire()
*
* @return mixed
*/
public function handle()
{
return $this->fire();
}
}
2 changes: 1 addition & 1 deletion src/Jackiedo/DotenvEditor/DotenvFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function parseLine($line)
$key = $this->normaliseKey($key);
$data = trim($data);

if (!$data) {
if (!$data && $data !== '0') {
$value = '';
$comment = '';
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Jackiedo/DotenvEditor/DotenvWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(DotenvFormatterContract $formatter)
protected function ensureFileIsWritable($filePath)
{
if ((is_file($filePath) && !is_writable($filePath)) || (!is_file($filePath) && !is_writable(dirname($filePath)))) {
throw new UnableWriteToFileException(sprintf('Unable to write to the file at %s.', $this->filePath));
throw new UnableWriteToFileException(sprintf('Unable to write to the file at %s.', $filePath));
}
}

Expand Down

0 comments on commit 646094f

Please sign in to comment.