Passed
Push — master ( 1796d4...19b46c )
by Miroslaw
05:54
created
src/Commands/EnvDelCommand.php 2 patches
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,13 +46,14 @@
 block discarded – undo
46 46
     {
47 47
         $key = $this->argument('key');
48 48
 
49
-        if (!is_null($key))
50
-            $this->isValidKey((string)$key);
49
+        if (!is_null($key)) {
50
+                    $this->isValidKey((string)$key);
51
+        }
51 52
 
52 53
         $env = new Env();
53
-        if (!$env->exists((string)$key))
54
-            $this->info("There is no variable {$key}");
55
-        else
54
+        if (!$env->exists((string)$key)) {
55
+                    $this->info("There is no variable {$key}");
56
+        } else
56 57
         {
57 58
             $env->deleteVariable((string)$key);
58 59
             $this->info("Variable '{$key}' has been deleted");
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,14 +47,14 @@
 block discarded – undo
47 47
         $key = $this->argument('key');
48 48
 
49 49
         if (!is_null($key))
50
-            $this->isValidKey((string)$key);
50
+            $this->isValidKey((string) $key);
51 51
 
52 52
         $env = new Env();
53
-        if (!$env->exists((string)$key))
53
+        if (!$env->exists((string) $key))
54 54
             $this->info("There is no variable {$key}");
55 55
         else
56 56
         {
57
-            $env->deleteVariable((string)$key);
57
+            $env->deleteVariable((string) $key);
58 58
             $this->info("Variable '{$key}' has been deleted");
59 59
         }
60 60
 
Please login to merge, or discard this patch.
src/Commands/EnvGetCommand.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,8 +73,9 @@
 block discarded – undo
73 73
     {
74 74
         $this->key = (string)$this->argument('key');
75 75
 
76
-        if (strlen($this->key))
77
-            $this->isValidKey($this->key);
76
+        if (strlen($this->key)) {
77
+                    $this->isValidKey($this->key);
78
+        }
78 79
 
79 80
         $this->json = (bool)$this->option('json');
80 81
         $this->keyValFormat = (bool)$this->option('key-value');
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function handle()
73 73
     {
74
-        $this->key = (string)$this->argument('key');
74
+        $this->key = (string) $this->argument('key');
75 75
 
76 76
         if (strlen($this->key))
77 77
             $this->isValidKey($this->key);
78 78
 
79
-        $this->json = (bool)$this->option('json');
80
-        $this->keyValFormat = (bool)$this->option('key-value');
79
+        $this->json = (bool) $this->option('json');
80
+        $this->keyValFormat = (bool) $this->option('key-value');
81 81
         $this->env = new Env();
82 82
 
83 83
         return $this->_printOutput();
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 
87 87
     private function _getEntireEnvContent()
88 88
     {
89
-        return ($this->json) ? json_encode($this->env->getVariables()) : $this->env->getEnvContent();;
89
+        return ($this->json) ? json_encode($this->env->getVariables()) : $this->env->getEnvContent(); ;
90 90
     }
91 91
 
92 92
     private function _printKeyValue()
93 93
     {
94 94
         $value = ($this->json) ? json_encode($this->env->getKeyValue($this->key)) : ($this->keyValFormat ? $this->env->getKeyValue($this->key) : $this->env->getValue($this->key));
95
-        return($this->json) ? (string)$value : ($this->keyValFormat ? "{$this->key}={$value[$this->key]}" : (string)$value);
95
+        return($this->json) ? (string) $value : ($this->keyValFormat ? "{$this->key}={$value[$this->key]}" : (string) $value);
96 96
     }
97 97
 
98 98
     private function _printOutput()
Please login to merge, or discard this patch.
src/Commands/EnvListCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
     public function handle()
59 59
     {
60 60
 
61
-        $this->json = (bool)$this->option('json');
61
+        $this->json = (bool) $this->option('json');
62 62
 
63 63
         $this->env = new Env();
64 64
         $this->line($this->_getEntireEnvContent());
Please login to merge, or discard this patch.
src/Env.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
         foreach ($env_lines as $line)
29 29
         {
30 30
             if (strlen(trim($line)) && !(strpos(trim($line), '#') === 0)) {
31
-                [$key, $val] = explode('=', (string)$line);
31
+                [$key, $val] = explode('=', (string) $line);
32 32
                 $this->_envVars[$key] = $this->_stripValue($val);
33 33
             }
34 34
         }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function exists(string $key): bool
44 44
     {
45
-        if (is_null($this->_envVars))
46
-            $this->_parse();
45
+        if (is_null($this->_envVars)) {
46
+                    $this->_parse();
47
+        }
47 48
 
48 49
         return isset($this->_envVars[$key]);
49 50
     }
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
      */
57 58
     public function getValue(string $key): string
58 59
     {
59
-        if (is_null($this->_envVars))
60
-            $this->_parse();
60
+        if (is_null($this->_envVars)) {
61
+                    $this->_parse();
62
+        }
61 63
 
62 64
         return $this->_envVars[$key] ?? '';
63 65
     }
@@ -71,8 +73,9 @@  discard block
 block discarded – undo
71 73
      */
72 74
     public function getKeyValue(string $key): array
73 75
     {
74
-        if (is_null($this->_envVars))
75
-            $this->_parse();
76
+        if (is_null($this->_envVars)) {
77
+                    $this->_parse();
78
+        }
76 79
 
77 80
         return [$key => $this->_envVars[$key]] ?? [];
78 81
     }
@@ -99,7 +102,9 @@  discard block
 block discarded – undo
99 102
         $this->_saved = false;
100 103
 
101 104
         $this->_parse();
102
-        if ($write) $this->write();
105
+        if ($write) {
106
+            $this->write();
107
+        }
103 108
 
104 109
         return $this->getValue($key);
105 110
 
@@ -120,8 +125,9 @@  discard block
 block discarded – undo
120 125
             $this->_changed = true;
121 126
             $this->_saved = false;
122 127
 
123
-            if ($write)
124
-                $this->write();
128
+            if ($write) {
129
+                            $this->write();
130
+            }
125 131
 
126 132
         }
127 133
 
Please login to merge, or discard this patch.
src/Commands/EnvSetCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         $value = $this->argument('value');
72 72
 
73 73
         if (is_null($value) || !$value) {
74
-            $parts = explode('=', (string)$key, 2);
74
+            $parts = explode('=', (string) $key, 2);
75 75
 
76 76
             if (count($parts) !== 2) {
77 77
                 throw new InvalidArgumentException('No value was set');
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
             [$key, $value] = $parts;
81 81
         }
82 82
 
83
-        if (Str::contains((string)$key, '=')) {
83
+        if (Str::contains((string) $key, '=')) {
84 84
             throw new InvalidArgumentException("Environment key should not contain '='");
85 85
         }
86 86
 
87
-        if (!$this->isValidKey((string)$key)) {
87
+        if (!$this->isValidKey((string) $key)) {
88 88
             throw new InvalidArgumentException('Invalid argument key');
89 89
         }
90 90
 
91
-        return [(string)$key, (string)$value];
91
+        return [(string) $key, (string) $value];
92 92
     }
93 93
 
94 94
 }
Please login to merge, or discard this patch.