Passed
Push — master ( 367093...00bfdb )
by IRFA
03:14
created
src/Console/Commands/TestingCommands.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 
11 11
 class TestingCommands extends Command
12 12
 {
13
-    private $error=0;
14
-    private $success=0;
13
+    private $error = 0;
14
+    private $success = 0;
15 15
     /**
16 16
      * The name and signature of the console command.
17 17
      *
@@ -52,80 +52,80 @@  discard block
 block discarded – undo
52 52
         $this->testManualLock($domain);        
53 53
         $this->testLocked($domain);         
54 54
         $this->testUnlock($domain);        
55
-        $end=time();
55
+        $end = time();
56 56
         $this->line('<fg=default>--------------------------------------------');
57
-        $this->line('<fg=default>Tested at: '.date('Y-m-d H:m:s',time()));
58
-        $this->line('<fg=default>Test time : '.(round(microtime(true) - $curTime,3)*1000)." ms");
57
+        $this->line('<fg=default>Tested at: '.date('Y-m-d H:m:s', time()));
58
+        $this->line('<fg=default>Test time : '.(round(microtime(true)-$curTime, 3) * 1000)." ms");
59 59
 
60 60
     }
61
-    private function testWrite($domain){
61
+    private function testWrite($domain) {
62 62
         $test = new Testing();
63
-         if( $test->testWriteEventFailedLogin($domain) AND $test->testWritable($domain)){
63
+         if ($test->testWriteEventFailedLogin($domain) AND $test->testWritable($domain)) {
64 64
            $this->line('<fg=default>Auto Lock : <fg=green>OK');
65
-        } elseif(!$test->testWritable($domain)){
65
+        } elseif (!$test->testWritable($domain)) {
66 66
             $this->success += 1;
67 67
             $this->line('<fg=default>Auto Lock : <fg=yellow>Warning (Permission denied)');
68
-        } else{
68
+        } else {
69 69
             $this->error += 1;
70 70
              $this->line('<fg=default>Auto Lock : <fg=red>Failed');
71 71
         }
72 72
     } 
73
-    private function testManualLock($domain){
73
+    private function testManualLock($domain) {
74 74
         $test = new Testing();
75
-         if( $test->testManualLocking($domain)){
75
+         if ($test->testManualLocking($domain)) {
76 76
             $this->success += 1;
77 77
            $this->line('<fg=default>Manual Lock : <fg=green>OK');
78
-        } else{
78
+        } else {
79 79
             $this->error += 1;
80 80
              $this->line('<fg=default>Manual Lock : <fg=red>Failed');
81 81
         }
82 82
     }
83
-    private function testUnlock($domain){
83
+    private function testUnlock($domain) {
84 84
         $test = new Testing();
85
-         if( $test->testUnlocking($domain)){
85
+         if ($test->testUnlocking($domain)) {
86 86
            $this->success += 1;
87 87
            $this->line('<fg=default>Unlock Account : <fg=green>OK');
88
-        } else{
88
+        } else {
89 89
              $this->error += 1;
90 90
              $this->line('<fg=default>Unlock Account : <fg=red>Failed');
91 91
         }
92 92
     }
93 93
 
94
-    private function testLocked($domain){
94
+    private function testLocked($domain) {
95 95
         $test = new Testing();
96
-         if( $test->testLockLogin($domain)){
96
+         if ($test->testLockLogin($domain)) {
97 97
            $this->success += 1;
98 98
            $this->line('<fg=default>Try Login with locked account : <fg=green>Account is Locked');
99
-        } else{
99
+        } else {
100 100
              $this->error += 1;
101 101
              $this->line('<fg=default>Try Login with locked account : <fg=red>Account logged in');
102 102
         }
103 103
     }
104 104
 
105
-    private function testConfigurations(){
105
+    private function testConfigurations() {
106 106
     	 $test = new Testing();
107 107
     	 $res  = $test->testConfig();
108 108
     	 
109 109
     	 	$table = new Table($this->output);
110 110
     	 	$this->line('<fg=cyan>Testing Config:');
111 111
             $table->setRows([
112
-                        ['<fg=default>login_attemps',isset($res['login_attemps']) ? $res['login_attemps']:"<fg=red>Not Found"],
113
-                        ['<fg=default>logging',isset($res['logging']) ? $res['logging']:"<fg=red>Not Found"],
114
-                        ['<fg=default>input_name',isset($res['input_name']) ? $res['input_name']:"<fg=red>Not Found"],
115
-                        ['<fg=default>redirect_url',isset($res['redirect_url']) ? $res['redirect_url']:"<fg=red>Not Found"],
116
-                        ['<fg=default>protected_action_path',isset($res['protected_action_path']) ? $res['protected_action_path']:"<fg=red>Not Found"],
117
-                        ['<fg=default>protected_middleware_group',isset($res['protected_middleware_group']) ? $res['protected_middleware_group']:"<fg=red>Not Found"],
118
-                        ['<fg=default>message_name',isset($res['message_name']) ? $res['message_name']:"<fg=red>Not Found"],
119
-                        ['<fg=default>enable_except_account',isset($res['enable_except_account']) ? $res['enable_except_account']:"<fg=red>Not Found"],
120
-                        ['<fg=default>except_account',isset($res['except_account']) ? $res['except_account']:"<fg=red>Not Found"],
112
+                        ['<fg=default>login_attemps', isset($res['login_attemps']) ? $res['login_attemps'] : "<fg=red>Not Found"],
113
+                        ['<fg=default>logging', isset($res['logging']) ? $res['logging'] : "<fg=red>Not Found"],
114
+                        ['<fg=default>input_name', isset($res['input_name']) ? $res['input_name'] : "<fg=red>Not Found"],
115
+                        ['<fg=default>redirect_url', isset($res['redirect_url']) ? $res['redirect_url'] : "<fg=red>Not Found"],
116
+                        ['<fg=default>protected_action_path', isset($res['protected_action_path']) ? $res['protected_action_path'] : "<fg=red>Not Found"],
117
+                        ['<fg=default>protected_middleware_group', isset($res['protected_middleware_group']) ? $res['protected_middleware_group'] : "<fg=red>Not Found"],
118
+                        ['<fg=default>message_name', isset($res['message_name']) ? $res['message_name'] : "<fg=red>Not Found"],
119
+                        ['<fg=default>enable_except_account', isset($res['enable_except_account']) ? $res['enable_except_account'] : "<fg=red>Not Found"],
120
+                        ['<fg=default>except_account', isset($res['except_account']) ? $res['except_account'] : "<fg=red>Not Found"],
121 121
                        
122 122
                     ]);
123 123
                         $table->render();
124
-    	 if($res['err'] > 0){
124
+    	 if ($res['err'] > 0) {
125 125
             $this->line('<fg=red>Config invalid, testing is canceled.');
126 126
             exit();
127 127
          }	
128
-    	 if($res['err'] > 0 AND !empty($res['file'])){
128
+    	 if ($res['err'] > 0 AND !empty($res['file'])) {
129 129
     	 	$this->line('<fg=red>Testing config failed, testing is canceled.');
130 130
     	 	$this->line($res['file']);
131 131
     	 	exit();
Please login to merge, or discard this patch.
src/Func/Testing.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 class Testing extends Core {
10 10
     private $ret = [];
11 11
 
12
-    public function testConfig(){
13
-        $this->ret=[];
12
+    public function testConfig() {
13
+        $this->ret = [];
14 14
          $this->ret['err'] = 0;
15 15
         
16 16
 
17
-        if(!empty(config('irfa.lockout'))){
17
+        if (!empty(config('irfa.lockout'))) {
18 18
             $this->confLoginAttemps();
19 19
             $this->confLogging();
20 20
             $this->confInput();
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
             $this->confExceptEnabled();
27 27
             $this->confExceptAccount();
28 28
   
29
-        } else{
30
-            $this->ret['err'] +=1;
29
+        } else {
30
+            $this->ret['err'] += 1;
31 31
             $this->ret['file'] = "<fg=yellow> Could't find config file. Try to run <fg=cyan>php artisan vendor:publish --tag=lockout-account"; 
32 32
         }
33 33
 
34 34
         return $this->ret;
35 35
     }
36
-	public function testWriteEventFailedLogin($username){
36
+	public function testWriteEventFailedLogin($username) {
37 37
 
38 38
     	$this->eventFailedLogin($username);
39 39
 
@@ -41,172 +41,172 @@  discard block
 block discarded – undo
41 41
 		$dir = config('irfa.lockout.lockout_file_path');
42 42
 		$path = $dir.md5($input);
43 43
 
44
-    	if(File::exists($path))
44
+    	if (File::exists($path))
45 45
         {
46 46
         	return true;
47 47
         } 
48 48
     		return false;
49 49
     }
50
-    public function testWritable($username){
50
+    public function testWritable($username) {
51 51
 		$input = $username;
52 52
 		$dir = config('irfa.lockout.lockout_file_path');
53 53
 		$path = $dir.md5($input);
54 54
 
55
-    	if(is_writable($path))
55
+    	if (is_writable($path))
56 56
         {
57 57
         	return true;
58 58
         } 
59 59
     		return false;
60 60
     }
61 61
 
62
-    public function testManualLocking($username){
62
+    public function testManualLocking($username) {
63 63
         $input = $username;
64 64
         $dir = config('irfa.lockout.lockout_file_path');
65 65
         $path = $dir.md5($input);
66 66
 
67
-        if($this->lock_account($username))
67
+        if ($this->lock_account($username))
68 68
         {
69 69
             return true;
70 70
         } 
71 71
             return false;
72 72
     }
73
-    public function testUnlocking($username){
73
+    public function testUnlocking($username) {
74 74
         $input = $username;
75 75
         $dir = config('irfa.lockout.lockout_file_path');
76 76
         $path = $dir.md5($input);
77
-        $unlock =  $this->test_unlock_account($username);
78
-        if($unlock)
77
+        $unlock = $this->test_unlock_account($username);
78
+        if ($unlock)
79 79
         {
80 80
             return true;
81 81
         } 
82 82
             return false;
83 83
     }
84
-    public function testLockLogin($username){
84
+    public function testLockLogin($username) {
85 85
         $input = $username;
86 86
         $dir = config('irfa.lockout.lockout_file_path');
87 87
         $path = $dir.md5($input);
88
-        $unlock =  $this->lockLogin($username);
89
-        if($unlock)
88
+        $unlock = $this->lockLogin($username);
89
+        if ($unlock)
90 90
         {
91 91
             return true;
92 92
         } 
93 93
             return false;
94 94
     }
95 95
 //////Config
96
-    private function confLoginAttemps(){
97
-            if(is_numeric(config('irfa.lockout.login_attemps'))){
96
+    private function confLoginAttemps() {
97
+            if (is_numeric(config('irfa.lockout.login_attemps'))) {
98 98
                 $this->ret['login_attemps'] = '<fg=green>OK';
99
-            } else{
99
+            } else {
100 100
 
101
-                $this->ret['err'] +=1;
102
-                $this->ret['login_attemps'] ='<fg=red>Must be a number';
101
+                $this->ret['err'] += 1;
102
+                $this->ret['login_attemps'] = '<fg=red>Must be a number';
103 103
             }
104 104
     }
105 105
 
106
-    private function confLogging(){
107
-       if(is_bool(config('irfa.lockout.logging'))){
106
+    private function confLogging() {
107
+       if (is_bool(config('irfa.lockout.logging'))) {
108 108
                $this->ret['logging'] = '<fg=green>OK';
109
-            } else{
109
+            } else {
110 110
 
111
-                $this->ret['err'] +=1;
111
+                $this->ret['err'] += 1;
112 112
                 $this->ret['logging'] = '<fg=red>Must be a Boolean'; 
113 113
             }
114 114
     }
115
-    private function confInput(){
115
+    private function confInput() {
116 116
        
117
-            if(is_string(config('irfa.lockout.input_name'))){
117
+            if (is_string(config('irfa.lockout.input_name'))) {
118 118
                 $this->ret['input_name'] = '<fg=green>OK';
119
-            } else{
119
+            } else {
120 120
 
121
-                $this->ret['err'] +=1;
121
+                $this->ret['err'] += 1;
122 122
                 $this->ret['input_name'] = '<fg=red>Must be a String'; 
123 123
             }
124 124
     }
125
-     private function confFilePath(){
125
+     private function confFilePath() {
126 126
        
127 127
             
128
-            if(is_writable(config('irfa.lockout.lockout_file_path'))){
128
+            if (is_writable(config('irfa.lockout.lockout_file_path'))) {
129 129
                 $this->ret['lockout_file_path'] = '<fg=green>OK';
130
-            } else{
130
+            } else {
131 131
                 $this->ret['lockout_file_path'] = '<fg=yellow>Write Permission Denied in '.config('irfa.lockout.lockout_file_path'); 
132 132
             }
133 133
         }
134
-    private function confRedirectUrl(){
135
-        if(!empty(config('irfa.lockout.redirect_url'))){
134
+    private function confRedirectUrl() {
135
+        if (!empty(config('irfa.lockout.redirect_url'))) {
136 136
                 $this->ret['redirect_url'] = '<fg=green>OK';
137
-            } else{
137
+            } else {
138 138
 
139
-                $this->ret['err'] +=1;
139
+                $this->ret['err'] += 1;
140 140
                 $this->ret['redirect_url'] = '<fg=red>Must be provided'; 
141 141
             }
142 142
     }
143
-    private function confProtectActionPath(){
144
-        if(is_array(config('irfa.lockout.protected_action_path'))){
143
+    private function confProtectActionPath() {
144
+        if (is_array(config('irfa.lockout.protected_action_path'))) {
145 145
                 $this->ret['protected_action_path'] = '<fg=green>OK';
146
-                 if(!empty(config('irfa.lockout.protected_action_path'))){
146
+                 if (!empty(config('irfa.lockout.protected_action_path'))) {
147 147
                     $this->ret['protected_action_path'] = '<fg=green>OK';
148
-                } else{
149
-                     $this->ret['err'] +=1;
148
+                } else {
149
+                     $this->ret['err'] += 1;
150 150
                      $this->ret['protected_action_path'] = '<fg=red>Must be provided'; 
151 151
                 }
152
-            } else{
152
+            } else {
153 153
 
154
-                $this->ret['err'] +=1;
154
+                $this->ret['err'] += 1;
155 155
                 $this->ret['protected_action_path'] = '<fg=red>Must be array'; 
156 156
             }
157 157
 
158 158
     }
159
-    private function confProtectMiddleware(){
160
-        if(is_array(config('irfa.lockout.protected_middleware_group'))){
161
-                if(!empty(config('irfa.lockout.protected_middleware_group'))){
159
+    private function confProtectMiddleware() {
160
+        if (is_array(config('irfa.lockout.protected_middleware_group'))) {
161
+                if (!empty(config('irfa.lockout.protected_middleware_group'))) {
162 162
                     $this->ret['protected_middleware_group'] = '<fg=green>OK';
163
-                } else{
164
-                     $this->ret['err'] +=1;
163
+                } else {
164
+                     $this->ret['err'] += 1;
165 165
                      $this->ret['protected_middleware_group'] = '<fg=red>Must be provided'; 
166 166
                 }
167
-            } else{
167
+            } else {
168 168
 
169
-                $this->ret['err'] +=1;
169
+                $this->ret['err'] += 1;
170 170
                 $this->ret['protected_middleware_group'] = '<fg=red>Must be array'; 
171 171
             }
172 172
 
173 173
     }
174
-    private function confMessage(){
175
-         if(is_string(config('irfa.lockout.message_name'))){
174
+    private function confMessage() {
175
+         if (is_string(config('irfa.lockout.message_name'))) {
176 176
                 $this->ret['message_name'] = '<fg=green>OK';
177
-            } else{
177
+            } else {
178 178
 
179
-                $this->ret['err'] +=1;
179
+                $this->ret['err'] += 1;
180 180
                 $this->ret['message_name'] = '<fg=red>Must be a String'; 
181 181
             }
182 182
 
183 183
     }
184
-     private function confExceptEnabled(){
185
-         if(is_bool(config('irfa.lockout.enable_except_account'))){
184
+     private function confExceptEnabled() {
185
+         if (is_bool(config('irfa.lockout.enable_except_account'))) {
186 186
                 $this->ret['enable_except_account'] = '<fg=green>OK';
187
-            } else{
187
+            } else {
188 188
 
189
-                $this->ret['err'] +=1;
189
+                $this->ret['err'] += 1;
190 190
                 $this->ret['enable_except_account'] = '<fg=red>Must be a String'; 
191 191
             }
192 192
 
193 193
     } 
194
-    private function confExceptAccount(){
195
-         if(is_array(config('irfa.lockout.except_account'))){
196
-                if(!empty(config('irfa.lockout.except_account'))){
194
+    private function confExceptAccount() {
195
+         if (is_array(config('irfa.lockout.except_account'))) {
196
+                if (!empty(config('irfa.lockout.except_account'))) {
197 197
                     $this->ret['except_account'] = '<fg=green>OK';
198
-                } else{
199
-                    if(config('irfa.lockout.enable_except_account')){
198
+                } else {
199
+                    if (config('irfa.lockout.enable_except_account')) {
200 200
 
201 201
                         $this->ret['except_account'] = '<fg=yellow>NOT SET';
202
-                    } else{
202
+                    } else {
203 203
 
204 204
                         $this->ret['except_account'] = '<fg=green>OK';
205 205
                     }
206 206
                 }
207
-            } else{
207
+            } else {
208 208
 
209
-                $this->ret['err'] +=1;
209
+                $this->ret['err'] += 1;
210 210
                 $this->ret['except_account'] = '<fg=red>Must be a array'; 
211 211
             }
212 212
 
Please login to merge, or discard this patch.