Passed
Push — master ( 055768...84c376 )
by Ioannes
01:40
created
src/Time24.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
     public function __construct($time = '') {
11 11
 
12 12
         $time = trim($time);
13
-        if(empty($time)) {
13
+        if (empty($time)) {
14 14
             \App\BxConsole\EnvHelper::timeZoneSet();
15 15
             $time = date("H:i:s");
16 16
         }
17 17
         $timeparts = array_map('intval', explode(':', $time));
18 18
 
19
-        if(isset($timeparts[0])) $this->setHours($timeparts[0]);
20
-        if(isset($timeparts[1])) $this->setMinutes($timeparts[1]);
21
-        if(isset($timeparts[2])) $this->setSeconds($timeparts[2]);
19
+        if (isset($timeparts[0])) $this->setHours($timeparts[0]);
20
+        if (isset($timeparts[1])) $this->setMinutes($timeparts[1]);
21
+        if (isset($timeparts[2])) $this->setSeconds($timeparts[2]);
22 22
     }
23 23
 
24 24
     /**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $timeparts = [];
39 39
         $timeparts[] = sprintf("%02d", $this->hours);
40 40
         $timeparts[] = sprintf("%02d", $this->minutes);
41
-        if($seconds) {
41
+        if ($seconds) {
42 42
             $timeparts[] = sprintf("%02d", $this->seconds);
43 43
         }
44 44
         return join(':', $timeparts);
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
     public function setHours($hours)
75 75
     {
76 76
         $hours = (int) $hours;
77
-        if($hours < 0) {
77
+        if ($hours < 0) {
78 78
             $hours = 0;
79
-        } else if($hours > 23) {
79
+        } else if ($hours > 23) {
80 80
             $hours = 23;
81 81
         }
82 82
         $this->hours = $hours;
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
     public function setMinutes($minutes)
89 89
     {
90 90
         $minutes = (int) $minutes;
91
-        if($minutes < 0) {
91
+        if ($minutes < 0) {
92 92
             $minutes = 0;
93
-        } else if($minutes > 59) {
93
+        } else if ($minutes > 59) {
94 94
             $minutes = 59;
95 95
         }
96 96
         $this->minutes = $minutes;
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
     public function setSeconds($seconds)
103 103
     {
104 104
         $seconds = (int) $seconds;
105
-        if($seconds < 0) {
105
+        if ($seconds < 0) {
106 106
             $seconds = 0;
107
-        } else if($seconds > 59) {
107
+        } else if ($seconds > 59) {
108 108
             $seconds = 59;
109 109
         }
110 110
         $this->seconds = $seconds;
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
     public static function validateTimeString($str) {
114 114
 
115 115
         $str = trim($str);
116
-        if(strpos($str, ':') !== false) {
116
+        if (strpos($str, ':') !== false) {
117 117
             $timeParts = explode(':', $str);
118
-            if(count($timeParts) == 2) {
118
+            if (count($timeParts) == 2) {
119 119
                 $timeParts[2] = '00';
120 120
             }
121 121
             $str = join(':', $timeParts);
122
-            if(preg_match("/^(?:2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]$/", $str)) {
122
+            if (preg_match("/^(?:2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]$/", $str)) {
123 123
                 return $str;
124 124
             }
125 125
         }
@@ -129,33 +129,33 @@  discard block
 block discarded – undo
129 129
     public static function inInterval($minStrTime, $maxStrTime, $checkStrTime = '') {
130 130
 
131 131
         $minTime = new self($minStrTime);
132
-        if($maxStrTime == '00:00') {
132
+        if ($maxStrTime == '00:00') {
133 133
             $maxStrTime = '23:59';
134 134
         }
135 135
         $maxTime = new self($maxStrTime);
136 136
         $checkTime = new self($checkStrTime);
137 137
 
138
-        if($minTime->getHours() == $checkTime->getHours()) {
139
-            if($minTime->getMinutes() == $checkTime->getMinutes()) {
140
-                if($minTime->getSeconds() > $checkTime->getSeconds()) {
138
+        if ($minTime->getHours() == $checkTime->getHours()) {
139
+            if ($minTime->getMinutes() == $checkTime->getMinutes()) {
140
+                if ($minTime->getSeconds() > $checkTime->getSeconds()) {
141 141
                     return false;
142 142
                 }
143
-            } else if($minTime->getMinutes() > $checkTime->getMinutes()) {
143
+            } else if ($minTime->getMinutes() > $checkTime->getMinutes()) {
144 144
                 return false;
145 145
             }
146
-        } else if($minTime->getHours() > $checkTime->getHours()) {
146
+        } else if ($minTime->getHours() > $checkTime->getHours()) {
147 147
             return false;
148 148
         }
149 149
 
150
-        if($maxTime->getHours() == $checkTime->getHours()) {
151
-            if($maxTime->getMinutes() == $checkTime->getMinutes()) {
152
-                if($minTime->getSeconds() < $checkTime->getSeconds()) {
150
+        if ($maxTime->getHours() == $checkTime->getHours()) {
151
+            if ($maxTime->getMinutes() == $checkTime->getMinutes()) {
152
+                if ($minTime->getSeconds() < $checkTime->getSeconds()) {
153 153
                     return false;
154 154
                 }
155
-            } else if($maxTime->getMinutes() < $checkTime->getMinutes()) {
155
+            } else if ($maxTime->getMinutes() < $checkTime->getMinutes()) {
156 156
                 return false;
157 157
             }
158
-        } else if($maxTime->getHours() < $checkTime->getHours()) {
158
+        } else if ($maxTime->getHours() < $checkTime->getHours()) {
159 159
             return false;
160 160
         }
161 161
 
Please login to merge, or discard this patch.
src/Bitrix/Loader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
      */
11 11
     public function initializeBitrix() {
12 12
 
13
-        if($this->checkBitrix()) {
13
+        if ($this->checkBitrix()) {
14 14
 
15 15
             if (defined('B_PROLOG_INCLUDED') && B_PROLOG_INCLUDED === true) {
16 16
                 return true;
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
             $cliFile = getLocalPath('modules/' . $module['ID'] . '/cli.php');
59 59
 
60
-            if(!$cliFile) {
60
+            if (!$cliFile) {
61 61
                 continue;
62 62
             }
63 63
 
Please login to merge, or discard this patch.
src/EnvHelper.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
     public static function loadEnv() {
19 19
 
20 20
         $envFile = realpath(__DIR__ . '/../../../../.env');
21
-        if(!is_file($envFile)) {
21
+        if (!is_file($envFile)) {
22 22
             $envFile = realpath(__DIR__ . '/../../../../../.env');
23 23
         }
24
-        if(is_file($envFile)) {
24
+        if (is_file($envFile)) {
25 25
             try {
26 26
                 $env = new \Symfony\Component\Dotenv\Dotenv();
27 27
                 $env->load($envFile);
@@ -36,19 +36,19 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public static function getDocumentRoot() {
38 38
 
39
-        if(isset($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['DOCUMENT_ROOT'])) {
39
+        if (isset($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['DOCUMENT_ROOT'])) {
40 40
             return $_SERVER['DOCUMENT_ROOT'];
41 41
         }
42 42
 
43
-        if(isset($_ENV['APP_DOCUMENT_ROOT']) && is_dir($_ENV['APP_DOCUMENT_ROOT'])) {
43
+        if (isset($_ENV['APP_DOCUMENT_ROOT']) && is_dir($_ENV['APP_DOCUMENT_ROOT'])) {
44 44
             $_SERVER['DOCUMENT_ROOT'] = $_ENV['APP_DOCUMENT_ROOT'];
45 45
             return $_SERVER['DOCUMENT_ROOT'];
46 46
         }
47 47
 
48 48
         $composerFile = realpath(__DIR__ . '/../../../../composer.json');
49
-        if(is_file($composerFile)) {
49
+        if (is_file($composerFile)) {
50 50
             $composerConfig = json_decode(file_get_contents($composerFile), true);
51
-            if(isset($composerConfig['extra']['document-root']) && is_dir($composerConfig['extra']['document-root'])) {
51
+            if (isset($composerConfig['extra']['document-root']) && is_dir($composerConfig['extra']['document-root'])) {
52 52
                 $_SERVER['DOCUMENT_ROOT'] = $composerConfig['extra']['document-root'];
53 53
                 return $_SERVER['DOCUMENT_ROOT'];
54 54
             }
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public static function getLogger($channel) {
67 67
 
68
-        if(isset($_ENV['APP_LOG_CLASS']) && class_exists($_ENV['APP_LOG_CLASS'])) {
68
+        if (isset($_ENV['APP_LOG_CLASS']) && class_exists($_ENV['APP_LOG_CLASS'])) {
69 69
             $logClass = $_ENV['APP_LOG_CLASS'];
70 70
             $log = new $logClass($channel);
71
-            if($log instanceof LoggerInterface) {
71
+            if ($log instanceof LoggerInterface) {
72 72
                 return $log;
73 73
             }
74 74
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public static function getCrontabFile() {
83 83
 
84
-        if(isset($_ENV['BX_CRONTAB_FOLDER']) && $_ENV['BX_CRONTAB_FOLDER']) {
84
+        if (isset($_ENV['BX_CRONTAB_FOLDER']) && $_ENV['BX_CRONTAB_FOLDER']) {
85 85
             return rtrim($_ENV['BX_CRONTAB_FOLDER'], "/") . '/bx_crontab.json';
86 86
         }
87 87
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
     public static function getCrontabTimeout() {
92 92
 
93
-        if(isset($_ENV['BX_CRONTAB_TIMEOUT']) && is_numeric($_ENV['BX_CRONTAB_TIMEOUT'])) {
93
+        if (isset($_ENV['BX_CRONTAB_TIMEOUT']) && is_numeric($_ENV['BX_CRONTAB_TIMEOUT'])) {
94 94
             return (int) $_ENV['BX_CRONTAB_TIMEOUT'];
95 95
         }
96 96
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
     public static function getBxCrontabPeriod() {
101 101
 
102
-        if(isset($_ENV['BX_CRONTAB_PERIOD']) && is_numeric($_ENV['BX_CRONTAB_PERIOD'])) {
102
+        if (isset($_ENV['BX_CRONTAB_PERIOD']) && is_numeric($_ENV['BX_CRONTAB_PERIOD'])) {
103 103
             return (int) $_ENV['BX_CRONTAB_PERIOD'];
104 104
         }
105 105
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 
109 109
     public static function getSwitch($name, $state) {
110 110
 
111
-        if(isset($_ENV[$name])) {
111
+        if (isset($_ENV[$name])) {
112 112
 
113 113
             $val = strtolower(trim($_ENV[$name]));
114
-            if($state == self::SWITCH_STATE_ON) {
115
-                if($val === self::SWITCH_STATE_ON || $val === '1' || $val === 'true') {
114
+            if ($state == self::SWITCH_STATE_ON) {
115
+                if ($val === self::SWITCH_STATE_ON || $val === '1' || $val === 'true') {
116 116
                     return true;
117 117
                 }
118
-            } else if($state == self::SWITCH_STATE_OFF) {
119
-                if($val === self::SWITCH_STATE_OFF || $val === '0' || $val === 'false') {
118
+            } else if ($state == self::SWITCH_STATE_OFF) {
119
+                if ($val === self::SWITCH_STATE_OFF || $val === '0' || $val === 'false') {
120 120
                     return true;
121 121
                 }
122 122
             }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
         $timeZone = self::BX_CRONTAB_TIMEZONE;
131 131
 
132
-        if(isset($_ENV['BX_CRONTAB_TIMEZONE']) && $_ENV['BX_CRONTAB_TIMEZONE']) {
132
+        if (isset($_ENV['BX_CRONTAB_TIMEZONE']) && $_ENV['BX_CRONTAB_TIMEZONE']) {
133 133
             $timeZone = trim($_ENV['BX_CRONTAB_TIMEZONE']);
134 134
         }
135 135
 
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
 
139 139
     public static function checkSleepInterval() {
140 140
 
141
-        if(isset($_ENV['BX_CRONTAB_SLEEP_TIME']) && $_ENV['BX_CRONTAB_SLEEP_TIME']) {
141
+        if (isset($_ENV['BX_CRONTAB_SLEEP_TIME']) && $_ENV['BX_CRONTAB_SLEEP_TIME']) {
142 142
             $intervals = explode(',', $_ENV['BX_CRONTAB_SLEEP_TIME']);
143
-            foreach($intervals as $interval) {
143
+            foreach ($intervals as $interval) {
144 144
                 $times = explode('-', $interval);
145
-                if(count($times) != 2) {
145
+                if (count($times) != 2) {
146 146
                     continue;
147 147
                 }
148 148
                 $minTime = Time24::validateTimeString($times[0]);
149 149
                 $maxTime = Time24::validateTimeString($times[1]);
150
-                if($minTime && $maxTime) {
151
-                    if(Time24::inInterval($minTime, $maxTime)) {
150
+                if ($minTime && $maxTime) {
151
+                    if (Time24::inInterval($minTime, $maxTime)) {
152 152
                         return $interval;
153 153
                     }
154 154
                 }
Please login to merge, or discard this patch.
src/Cron.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -40,45 +40,45 @@  discard block
 block discarded – undo
40 40
         set_time_limit(EnvHelper::getCrontabTimeout());
41 41
 
42 42
         $logger = EnvHelper::getLogger('bx_cron');
43
-        if($logger) {
43
+        if ($logger) {
44 44
             $this->setLogger($logger);
45 45
         }
46 46
 
47 47
         $showStatus = $input->getOption('status');
48 48
         $byTime = $input->getOption('bytime');
49
-        if($showStatus) {
49
+        if ($showStatus) {
50 50
             $sort = ($byTime ? self::SORT_TIME : self::SORT_NAME);
51 51
             $this->showStatus($output, $sort);
52 52
             return 0;
53 53
         }
54 54
 
55
-        if(EnvHelper::getSwitch('BX_CRONTAB_RUN', EnvHelper::SWITCH_STATE_OFF)) {
56
-            if($this->logger) {
55
+        if (EnvHelper::getSwitch('BX_CRONTAB_RUN', EnvHelper::SWITCH_STATE_OFF)) {
56
+            if ($this->logger) {
57 57
                 $this->logger->alert('BxCron switch off');
58 58
             }
59 59
             return 0;
60 60
         }
61 61
 
62
-        if(!$this->lock()) {
62
+        if (!$this->lock()) {
63 63
             $msg = 'The command is already running in another process.';
64 64
             $output->writeln($msg);
65
-            if($this->logger) {
65
+            if ($this->logger) {
66 66
                 $this->logger->warning($msg);
67 67
             }
68 68
             return 0;
69 69
         }
70 70
 
71
-        if($sleepInterval = EnvHelper::checkSleepInterval()) {
71
+        if ($sleepInterval = EnvHelper::checkSleepInterval()) {
72 72
             $msg = sprintf("Sleep in interval %s", $sleepInterval);
73 73
             $output->writeln($msg);
74
-            if($this->logger) {
74
+            if ($this->logger) {
75 75
                 $this->logger->warning($msg);
76 76
             }
77 77
             return 0;
78 78
         }
79 79
 
80 80
         $clean = $input->getOption('clean');
81
-        if($clean) {
81
+        if ($clean) {
82 82
             $command = $this->getApplication()->find($clean);
83 83
             $this->cleanJob($command->getName());
84 84
             $output->writeln($command->getName() . " will be executed now");
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         $cleanAll = $input->getOption('all');
89
-        if($cleanAll) {
89
+        if ($cleanAll) {
90 90
             $this->cleanJob();
91 91
             $output->writeln("All commands will be executed now");
92 92
             return 0;
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
         $lastExec = 0;
110 110
         $hasError = false;
111 111
 
112
-        foreach($jobs as $cmd => $job) {
112
+        foreach ($jobs as $cmd => $job) {
113 113
             $execTime = $job['last_exec'];
114
-            if($execTime > $lastExec) $lastExec = $execTime;
115
-            if(!empty($job['error'])) {
114
+            if ($execTime > $lastExec) $lastExec = $execTime;
115
+            if (!empty($job['error'])) {
116 116
                 $hasError = true;
117 117
             }
118 118
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             'Status',
132 132
         ];
133 133
 
134
-        if($hasError) {
134
+        if ($hasError) {
135 135
             $header[] = 'Error';
136 136
         }
137 137
 
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
         ]);
142 142
 
143 143
         $cnt = 1;
144
-        foreach($jobs as $cmd => $job) {
145
-            if($cnt > 1) $table->addRow(new TableSeparator());
144
+        foreach ($jobs as $cmd => $job) {
145
+            if ($cnt > 1) $table->addRow(new TableSeparator());
146 146
             $row = [
147 147
                 $cmd,
148 148
                 $job['period'],
149 149
                 ($job['last_exec'] ? date("d.m.Y H:i:s", $job['last_exec']) : 'NONE'),
150 150
                 $job['status'],
151 151
             ];
152
-            if($hasError) {
152
+            if ($hasError) {
153 153
                 $row[] = $job['error'];
154 154
             }
155 155
             $table->addRow($row);
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 
164 164
         $crontab = [];
165 165
 
166
-        if($command) {
166
+        if ($command) {
167 167
             $crontab = $this->getCronTab();
168
-            if($crontab === false) {
168
+            if ($crontab === false) {
169 169
                 return false;
170 170
             }
171 171
             unset($crontab[$command]);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 
179 179
         $jobs = $this->getCronJobs();
180 180
 
181
-        if(is_array($jobs) && !empty($jobs)) {
181
+        if (is_array($jobs) && !empty($jobs)) {
182 182
 
183 183
             /*
184 184
              * Минимально допустимый период выполнения одной задачи
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
              */
187 187
             $this->minAgentPeriod = (count($jobs) + 1) * EnvHelper::getBxCrontabPeriod();
188 188
 
189
-            foreach($jobs as $cmd => $job) {
189
+            foreach ($jobs as $cmd => $job) {
190 190
 
191
-                if($this->isActualJob($job)) {
191
+                if ($this->isActualJob($job)) {
192 192
 
193 193
                     $job['status'] = self::EXEC_STATUS_WORK;
194 194
                     $this->updaateJob($cmd, $job);
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
                         $timeStart = microtime(true);
201 201
                         $returnCode = $command->run($cmdInput, $output);
202 202
 
203
-                        if(!$returnCode) {
203
+                        if (!$returnCode) {
204 204
 
205 205
                             $job['status'] = self::EXEC_STATUS_SUCCESS;
206 206
 
207 207
                             $msg = sprintf("%s: SUCCESS [%.2f s]", $cmd, microtime(true) - $timeStart);
208
-                            if($this->logger) {
208
+                            if ($this->logger) {
209 209
                                 $this->logger->alert($msg);
210 210
                             }
211 211
                             $output->writeln(PHP_EOL . $msg);
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
                             $job['error_code'] = $returnCode;
217 217
 
218 218
                             $msg = sprintf("%s: ERROR [%.2f s]", $cmd, microtime(true) - $timeStart);
219
-                            if($this->logger) {
219
+                            if ($this->logger) {
220 220
                                 $this->logger->alert($msg);
221 221
                             }
222 222
                             $output->writeln(PHP_EOL . $msg);
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                         $job['error'] = $e->getMessage();
229 229
 
230 230
 
231
-                        if($this->logger) {
231
+                        if ($this->logger) {
232 232
                             $this->logger->error($e, ['command' => $cmd]);
233 233
                         }
234 234
                         $output->writeln(PHP_EOL . 'ERROR: ' . $e->getMessage());
@@ -250,21 +250,21 @@  discard block
 block discarded – undo
250 250
 
251 251
     protected function isActualJob(&$job) {
252 252
 
253
-        if(isset($job['status']) && $job['status'] !== self::EXEC_STATUS_SUCCESS) {
253
+        if (isset($job['status']) && $job['status'] !== self::EXEC_STATUS_SUCCESS) {
254 254
             return false;
255 255
         }
256 256
 
257 257
         $period = intval($job['period']);
258 258
 
259
-        if($period > 0) {
260
-            if($period < $this->minAgentPeriod) {
259
+        if ($period > 0) {
260
+            if ($period < $this->minAgentPeriod) {
261 261
                 $job['orig_period'] = $period;
262 262
                 $period = $job['period'] = $this->minAgentPeriod;
263 263
             }
264
-            if(time() - $job['last_exec'] >= $period) {
264
+            if (time() - $job['last_exec'] >= $period) {
265 265
                 return true;
266 266
             }
267
-        } else if(!empty($job['times'])) {
267
+        } else if (!empty($job['times'])) {
268 268
             //TODO:
269 269
         }
270 270
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     public function getCronJobs() {
275 275
 
276 276
         $crontab = $this->getCronTab();
277
-        if($crontab === false) {
277
+        if ($crontab === false) {
278 278
             return false;
279 279
         }
280 280
 
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
         $commands = $app->all();
285 285
 
286 286
         $selfCommands = [];
287
-        foreach($commands as $command) {
287
+        foreach ($commands as $command) {
288 288
             /** @var BxCommand $command */
289
-            if($command instanceof BxCommand) {
289
+            if ($command instanceof BxCommand) {
290 290
                 $name = $command->getName();
291 291
                 $selfCommands[$name] = [
292 292
                     'object' => $command,
@@ -296,19 +296,19 @@  discard block
 block discarded – undo
296 296
 
297 297
         $agents = [];
298 298
         $reader = new AnnotationReader();
299
-        foreach($selfCommands as $cmd => $selfCommand) {
299
+        foreach ($selfCommands as $cmd => $selfCommand) {
300 300
             $reflectionClass = new \ReflectionClass($selfCommand['object']);
301 301
             $annotations = $reader->getClassAnnotations($reflectionClass);
302 302
 
303
-            foreach($annotations as $annotation) {
304
-                if($annotation instanceof Agent) {
303
+            foreach ($annotations as $annotation) {
304
+                if ($annotation instanceof Agent) {
305 305
                     $agents[$cmd] = $annotation->toArray();
306 306
                 }
307 307
             }
308 308
         }
309 309
 
310
-        foreach($crontab as $cmd => $job) {
311
-            if(is_array($job) && isset($agents[$cmd])) {
310
+        foreach ($crontab as $cmd => $job) {
311
+            if (is_array($job) && isset($agents[$cmd])) {
312 312
                 $agents[$cmd] = array_merge($job, $agents[$cmd]);
313 313
             }
314 314
         }
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
         $crontab = $this->getCronTab();
329 329
 
330
-        if($crontab === false) {
330
+        if ($crontab === false) {
331 331
             return false;
332 332
         } else {
333 333
             $crontab = array_merge($crontab, $changedAgents);
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         $fh = fopen($filename, 'c');
346 346
         if (flock($fh, LOCK_EX)) {
347 347
             ftruncate($fh, 0);
348
-            if(!fwrite($fh, json_encode($agents, JSON_PRETTY_PRINT))) {
348
+            if (!fwrite($fh, json_encode($agents, JSON_PRETTY_PRINT))) {
349 349
                 throw new \Exception('Unable to write BX_CRONTAB : ' . $filename);
350 350
             }
351 351
         } else {
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
         $filename = EnvHelper::getCrontabFile();
366 366
 
367 367
         $fh = fopen($filename, 'r');
368
-        if(flock($fh, LOCK_SH)) {
368
+        if (flock($fh, LOCK_SH)) {
369 369
             $cronTab = [];
370
-            if($data = fread($fh, filesize($filename))) {
370
+            if ($data = fread($fh, filesize($filename))) {
371 371
                 $decoded = json_decode($data, true);
372
-                if(is_array($decoded)) {
372
+                if (is_array($decoded)) {
373 373
                     $cronTab = $decoded;
374 374
                 }
375 375
             }
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
 
385 385
     protected function sortCronTab(array &$crontab, $sort = self::SORT_NAME) {
386 386
 
387
-        if($sort == self::SORT_TIME) {
387
+        if ($sort == self::SORT_TIME) {
388 388
             $sorting = [];
389
-            foreach($crontab as $cmd => $data) {
389
+            foreach ($crontab as $cmd => $data) {
390 390
                 $sorting[$cmd] = $data['last_exec'];
391 391
             }
392 392
             arsort($sorting, SORT_NUMERIC);
393 393
             $sorted = [];
394
-            foreach($sorting as $cmd => $time) {
394
+            foreach ($sorting as $cmd => $time) {
395 395
                 $sorted[$cmd] = $crontab[$cmd];
396 396
             }
397 397
             $crontab = $sorted;
Please login to merge, or discard this patch.
src/AsyncTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
         /** @var Command $command */
12 12
         $command = new self();
13 13
 
14
-        if(empty($logFile)) {
14
+        if (empty($logFile)) {
15 15
             $logFile = '/dev/null';
16 16
         } else {
17 17
             $logFile = $_ENV['APP_CMD_LOG_PATH'] . $logFile;
Please login to merge, or discard this patch.
src/BxCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@
 block discarded – undo
47 47
         /** @var Command $annotation */
48 48
         $annotation = $this->getAnnotation(\App\BxConsole\Annotations\Command::class);
49 49
 
50
-        if($annotation) {
50
+        if ($annotation) {
51 51
             $this->setName($annotation->name);
52 52
             $this->setDescription($annotation->description);
53
-            if($annotation->help) {
53
+            if ($annotation->help) {
54 54
                 $this->setHelp($annotation->help);
55 55
             }
56 56
         }
Please login to merge, or discard this patch.
src/Application.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
 
28 28
         $this->isBitrixLoaded = $loader->initializeBitrix();
29 29
 
30
-        if($this->isBitrixLoaded) {
31
-            foreach($loader->getModulesCommands() as $command) {
30
+        if ($this->isBitrixLoaded) {
31
+            foreach ($loader->getModulesCommands() as $command) {
32 32
                 $this->add($command);
33 33
             }
34 34
         }
35 35
 
36 36
         $pas4CliNamespace = EnvHelper::getPsr4CliNamespace();
37 37
         $loaders = ClassLoader::getRegisteredLoaders();
38
-        if(!empty($loaders)) {
38
+        if (!empty($loaders)) {
39 39
             $loader = current($loaders);
40
-            if($loader instanceof ClassLoader) {
40
+            if ($loader instanceof ClassLoader) {
41 41
                 $map = $loader->getClassMap();
42
-                foreach($map as $class => $path) {
43
-                    if(strpos($class, $pas4CliNamespace) === 0) {
42
+                foreach ($map as $class => $path) {
43
+                    if (strpos($class, $pas4CliNamespace) === 0) {
44 44
                         try {
45 45
                             $obj = new $class();
46
-                            if($obj instanceof Command) {
46
+                            if ($obj instanceof Command) {
47 47
                                 $this->add($obj);
48 48
                             }
49 49
                         } catch (\Exception $e) { }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
         $exitCode = parent::doRun($input, $output);
61 61
 
62
-        if($this->isBitrixLoaded) {
62
+        if ($this->isBitrixLoaded) {
63 63
             if ($this->getCommandName($input) === null) {
64 64
                 $output->writeln(PHP_EOL . sprintf('Using Bitrix <info>kernel v%s</info>.</info>', SM_VERSION),
65 65
                     OutputInterface::VERBOSITY_VERY_VERBOSE);
Please login to merge, or discard this patch.