Skip to content

Commit bc8c7bc

Browse files
committed
Update artisan commands
- Change method declaration location (stringToType). - Fixed input argument conversion for set-key command.
1 parent a55eecf commit bc8c7bc

File tree

6 files changed

+32
-156
lines changed

6 files changed

+32
-156
lines changed

src/Console/Commands/DotenvBackupCommand.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -48,37 +48,6 @@ public function fire()
4848
$this->info("Your file was backed up successfully at path [{$backup['filepath']}].");
4949
}
5050

51-
/**
52-
* Convert string to corresponding type.
53-
*
54-
* @param string $string
55-
*
56-
* @return mixed
57-
*/
58-
protected function stringToType($string)
59-
{
60-
if (is_string($string)) {
61-
switch (true) {
62-
case 'null' == $string || 'NULL' == $string:
63-
$string = null;
64-
break;
65-
66-
case 'true' == $string || 'TRUE' == $string:
67-
$string = true;
68-
break;
69-
70-
case 'false' == $string || 'FALSE' == $string:
71-
$string = false;
72-
break;
73-
74-
default:
75-
break;
76-
}
77-
}
78-
79-
return $string;
80-
}
81-
8251
/**
8352
* Get the console command arguments.
8453
*

src/Console/Commands/DotenvDeleteKeyCommand.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,6 @@ protected function transferInputsToProperties()
7272
$this->key = $this->argument('key');
7373
}
7474

75-
/**
76-
* Convert string to corresponding type.
77-
*
78-
* @param string $string
79-
*
80-
* @return mixed
81-
*/
82-
protected function stringToType($string)
83-
{
84-
if (is_string($string)) {
85-
switch (true) {
86-
case 'null' == $string || 'NULL' == $string:
87-
$string = null;
88-
break;
89-
90-
case 'true' == $string || 'TRUE' == $string:
91-
$string = true;
92-
break;
93-
94-
case 'false' == $string || 'FALSE' == $string:
95-
$string = false;
96-
break;
97-
98-
default:
99-
break;
100-
}
101-
}
102-
103-
return $string;
104-
}
105-
10675
/**
10776
* Get the console command arguments.
10877
*

src/Console/Commands/DotenvGetKeysCommand.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -65,37 +65,6 @@ public function fire()
6565
$this->info("You have total {$total} keys in your file");
6666
}
6767

68-
/**
69-
* Convert string to corresponding type.
70-
*
71-
* @param string $string
72-
*
73-
* @return mixed
74-
*/
75-
protected function stringToType($string)
76-
{
77-
if (is_string($string)) {
78-
switch (true) {
79-
case 'null' == $string || 'NULL' == $string:
80-
$string = null;
81-
break;
82-
83-
case 'true' == $string || 'TRUE' == $string:
84-
$string = true;
85-
break;
86-
87-
case 'false' == $string || 'FALSE' == $string:
88-
$string = false;
89-
break;
90-
91-
default:
92-
break;
93-
}
94-
}
95-
96-
return $string;
97-
}
98-
9968
/**
10069
* Get the console command arguments.
10170
*

src/Console/Commands/DotenvRestoreCommand.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,6 @@ protected function transferInputsToProperties()
7272
$this->restorePath = (is_string($restorePath)) ? base_path($restorePath) : null;
7373
}
7474

75-
/**
76-
* Convert string to corresponding type.
77-
*
78-
* @param string $string
79-
*
80-
* @return mixed
81-
*/
82-
protected function stringToType($string)
83-
{
84-
if (is_string($string)) {
85-
switch (true) {
86-
case 'null' == $string || 'NULL' == $string:
87-
$string = null;
88-
break;
89-
90-
case 'true' == $string || 'TRUE' == $string:
91-
$string = true;
92-
break;
93-
94-
case 'false' == $string || 'FALSE' == $string:
95-
$string = false;
96-
break;
97-
98-
default:
99-
break;
100-
}
101-
}
102-
103-
return $string;
104-
}
105-
10675
/**
10776
* Get the console command arguments.
10877
*

src/Console/Commands/DotenvSetKeyCommand.php

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -114,42 +114,11 @@ protected function transferInputsToProperties()
114114
$this->restorePath = (is_string($restorePath)) ? base_path($restorePath) : null;
115115

116116
$this->key = $this->argument('key');
117-
$this->value = $this->stringToType($this->argument('value'));
117+
$this->value = $this->argument('value');
118118
$this->comment = $this->stringToType($this->argument('comment'));
119119
$this->exportKey = $this->option('export-key');
120120
}
121121

122-
/**
123-
* Convert string to corresponding type.
124-
*
125-
* @param string $string
126-
*
127-
* @return mixed
128-
*/
129-
protected function stringToType($string)
130-
{
131-
if (is_string($string)) {
132-
switch (true) {
133-
case 'null' == $string || 'NULL' == $string:
134-
$string = null;
135-
break;
136-
137-
case 'true' == $string || 'TRUE' == $string:
138-
$string = true;
139-
break;
140-
141-
case 'false' == $string || 'FALSE' == $string:
142-
$string = false;
143-
break;
144-
145-
default:
146-
break;
147-
}
148-
}
149-
150-
return $string;
151-
}
152-
153122
/**
154123
* Get the console command arguments.
155124
*

src/Console/Traits/CreateCommandInstanceTrait.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,35 @@ public function handle()
3636
{
3737
return $this->fire();
3838
}
39+
40+
/**
41+
* Convert string to corresponding type.
42+
*
43+
* @param string $string
44+
*
45+
* @return mixed
46+
*/
47+
protected function stringToType($string)
48+
{
49+
if (is_string($string)) {
50+
switch (true) {
51+
case 'null' == $string || 'NULL' == $string:
52+
$string = null;
53+
break;
54+
55+
case 'true' == $string || 'TRUE' == $string:
56+
$string = true;
57+
break;
58+
59+
case 'false' == $string || 'FALSE' == $string:
60+
$string = false;
61+
break;
62+
63+
default:
64+
break;
65+
}
66+
}
67+
68+
return $string;
69+
}
3970
}

0 commit comments

Comments
 (0)