Passed
Push — master ( e49e3e...821da0 )
by Ioannes
01:42
created
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
             /**
16 16
              * Declare global legacy variables
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
             $cliFile = getLocalPath('modules/' . $module['ID'] . '/cli.php');
55 55
 
56
-            if(!$cliFile) {
56
+            if (!$cliFile) {
57 57
                 continue;
58 58
             }
59 59
 
Please login to merge, or discard this patch.
src/BxCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 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 53
             $this->setHelp($annotation->help);
Please login to merge, or discard this patch.
src/Application.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 
26 26
         $this->isBitrixLoaded = $loader->initializeBitrix();
27 27
 
28
-        if($this->isBitrixLoaded) {
29
-            foreach($loader->getModulesCommands() as $command) {
28
+        if ($this->isBitrixLoaded) {
29
+            foreach ($loader->getModulesCommands() as $command) {
30 30
                 $this->add($command);
31 31
             }
32 32
         }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
         $exitCode = parent::doRun($input, $output);
40 40
 
41
-        if($this->isBitrixLoaded) {
41
+        if ($this->isBitrixLoaded) {
42 42
             if ($this->getCommandName($input) === null) {
43 43
                 $output->writeln(PHP_EOL . sprintf('Using Bitrix <info>kernel v%s</info>.</info>', SM_VERSION),
44 44
                     OutputInterface::VERBOSITY_VERY_VERBOSE);
Please login to merge, or discard this patch.
src/EnvHelper.php 1 patch
Spacing   +21 added lines, -21 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);
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 
39 39
         $_SERVER['DOCUMENT_ROOT'] = realpath(__DIR__ . '/../../../../');
40 40
 
41
-        if(isset($_ENV['APP_DOCUMENT_ROOT']) && is_dir($_ENV['APP_DOCUMENT_ROOT'])) {
41
+        if (isset($_ENV['APP_DOCUMENT_ROOT']) && is_dir($_ENV['APP_DOCUMENT_ROOT'])) {
42 42
             $_SERVER['DOCUMENT_ROOT'] = $_ENV['APP_DOCUMENT_ROOT'];
43 43
             return $_SERVER['DOCUMENT_ROOT'];
44 44
         }
45 45
 
46 46
         $composerFile = realpath(__DIR__ . '/../../../../composer.json');
47
-        if(is_file($composerFile)) {
47
+        if (is_file($composerFile)) {
48 48
             $composerConfig = json_decode(file_get_contents($composerFile), true);
49
-            if(isset($composerConfig['extra']['document-root']) && is_dir($composerConfig['extra']['document-root'])) {
49
+            if (isset($composerConfig['extra']['document-root']) && is_dir($composerConfig['extra']['document-root'])) {
50 50
                 $_SERVER['DOCUMENT_ROOT'] = $composerConfig['extra']['document-root'];
51 51
                 return $_SERVER['DOCUMENT_ROOT'];
52 52
             }
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public static function getLogger($channel) {
63 63
 
64
-        if(isset($_ENV['APP_LOG_CLASS']) && class_exists($_ENV['APP_LOG_CLASS'])) {
64
+        if (isset($_ENV['APP_LOG_CLASS']) && class_exists($_ENV['APP_LOG_CLASS'])) {
65 65
             $logClass = $_ENV['APP_LOG_CLASS'];
66 66
             $log = new $logClass($channel);
67
-            if($log instanceof LoggerInterface) {
67
+            if ($log instanceof LoggerInterface) {
68 68
                 return $log;
69 69
             }
70 70
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public static function getCrontabFile() {
79 79
 
80
-        if(isset($_ENV['BX_CRONTAB_FOLDER']) && $_ENV['BX_CRONTAB_FOLDER']) {
80
+        if (isset($_ENV['BX_CRONTAB_FOLDER']) && $_ENV['BX_CRONTAB_FOLDER']) {
81 81
             return rtrim($_ENV['BX_CRONTAB_FOLDER'], "/") . '/bx_crontab.json';
82 82
         }
83 83
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
     public static function getCrontabTimeout() {
88 88
 
89
-        if(isset($_ENV['BX_CRONTAB_FOLDER']) && is_numeric($_ENV['BX_CRONTAB_FOLDER'])) {
89
+        if (isset($_ENV['BX_CRONTAB_FOLDER']) && is_numeric($_ENV['BX_CRONTAB_FOLDER'])) {
90 90
             return (int) $_ENV['BX_CRONTAB_FOLDER'];
91 91
         }
92 92
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
     public static function getBxCrontabPeriod() {
97 97
 
98
-        if(isset($_ENV['BX_CRONTAB_PERIOD']) && is_numeric($_ENV['BX_CRONTAB_PERIOD'])) {
98
+        if (isset($_ENV['BX_CRONTAB_PERIOD']) && is_numeric($_ENV['BX_CRONTAB_PERIOD'])) {
99 99
             return (int) $_ENV['BX_CRONTAB_PERIOD'];
100 100
         }
101 101
 
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 
105 105
     public static function getSwitch($name, $state) {
106 106
 
107
-        if(isset($_ENV[$name])) {
107
+        if (isset($_ENV[$name])) {
108 108
 
109 109
             $val = strtolower(trim($_ENV[$name]));
110
-            if($state == self::SWITCH_STATE_ON) {
111
-                if($val === self::SWITCH_STATE_ON || $val === '1' || $val === 'true') {
110
+            if ($state == self::SWITCH_STATE_ON) {
111
+                if ($val === self::SWITCH_STATE_ON || $val === '1' || $val === 'true') {
112 112
                     return true;
113 113
                 }
114
-            } else if($state == self::SWITCH_STATE_OFF) {
115
-                if($val === self::SWITCH_STATE_OFF || $val === '0' || $val === 'false') {
114
+            } else if ($state == self::SWITCH_STATE_OFF) {
115
+                if ($val === self::SWITCH_STATE_OFF || $val === '0' || $val === 'false') {
116 116
                     return true;
117 117
                 }
118 118
             }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         $timeZone = self::BX_CRONTAB_TIMEZONE;
127 127
 
128
-        if(isset($_ENV['BX_CRONTAB_TIMEZONE']) && $_ENV['BX_CRONTAB_TIMEZONE']) {
128
+        if (isset($_ENV['BX_CRONTAB_TIMEZONE']) && $_ENV['BX_CRONTAB_TIMEZONE']) {
129 129
             $timeZone = trim($_ENV['BX_CRONTAB_TIMEZONE']);
130 130
         }
131 131
 
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 
135 135
     public static function checkSleepInterval() {
136 136
 
137
-        if(isset($_ENV['BX_CRONTAB_SLEEP_TIME']) && $_ENV['BX_CRONTAB_SLEEP_TIME']) {
137
+        if (isset($_ENV['BX_CRONTAB_SLEEP_TIME']) && $_ENV['BX_CRONTAB_SLEEP_TIME']) {
138 138
             $intervals = explode(',', $_ENV['BX_CRONTAB_SLEEP_TIME']);
139
-            foreach($intervals as $interval) {
139
+            foreach ($intervals as $interval) {
140 140
                 $times = explode('-', $interval);
141
-                if(count($times) != 2) {
141
+                if (count($times) != 2) {
142 142
                     continue;
143 143
                 }
144 144
                 $minTime = Time24::validateTimeString($times[0]);
145 145
                 $maxTime = Time24::validateTimeString($times[1]);
146
-                if($minTime && $maxTime) {
147
-                    if(Time24::inInterval($minTime, $maxTime)) {
146
+                if ($minTime && $maxTime) {
147
+                    if (Time24::inInterval($minTime, $maxTime)) {
148 148
                         return $interval;
149 149
                     }
150 150
                 }
Please login to merge, or discard this patch.
src/Time24.php 2 patches
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.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,15 @@
 block discarded – undo
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])) {
20
+            $this->setHours($timeparts[0]);
21
+        }
22
+        if(isset($timeparts[1])) {
23
+            $this->setMinutes($timeparts[1]);
24
+        }
25
+        if(isset($timeparts[2])) {
26
+            $this->setSeconds($timeparts[2]);
27
+        }
22 28
     }
23 29
 
24 30
     /**
Please login to merge, or discard this patch.
src/Cron.php 2 patches
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -37,45 +37,45 @@  discard block
 block discarded – undo
37 37
     protected function execute(InputInterface $input, OutputInterface $output)
38 38
     {
39 39
         $logger = EnvHelper::getLogger('bx_cron');
40
-        if($logger) {
40
+        if ($logger) {
41 41
             $this->setLogger($logger);
42 42
         }
43 43
 
44 44
         $showStatus = $input->getOption('status');
45 45
         $byTime = $input->getOption('bytime');
46
-        if($showStatus) {
46
+        if ($showStatus) {
47 47
             $sort = ($byTime ? self::SORT_TIME : self::SORT_NAME);
48 48
             $this->showStatus($output, $sort);
49 49
             return 0;
50 50
         }
51 51
 
52
-        if(EnvHelper::getSwitch('BX_CRONTAB_RUN', EnvHelper::SWITCH_STATE_OFF)) {
53
-            if($this->logger) {
52
+        if (EnvHelper::getSwitch('BX_CRONTAB_RUN', EnvHelper::SWITCH_STATE_OFF)) {
53
+            if ($this->logger) {
54 54
                 $this->logger->alert('BxCron switch off');
55 55
             }
56 56
             return 0;
57 57
         }
58 58
 
59
-        if(!$this->lock()) {
59
+        if (!$this->lock()) {
60 60
             $msg = 'The command is already running in another process.';
61 61
             $output->writeln($msg);
62
-            if($this->logger) {
62
+            if ($this->logger) {
63 63
                 $this->logger->warning($msg);
64 64
             }
65 65
             return 0;
66 66
         }
67 67
 
68
-        if($sleepInterval = EnvHelper::checkSleepInterval()) {
68
+        if ($sleepInterval = EnvHelper::checkSleepInterval()) {
69 69
             $msg = sprintf("Sleep in interval %s", $sleepInterval);
70 70
             $output->writeln($msg);
71
-            if($this->logger) {
71
+            if ($this->logger) {
72 72
                 $this->logger->warning($msg);
73 73
             }
74 74
             return 0;
75 75
         }
76 76
 
77 77
         $clean = $input->getOption('clean');
78
-        if($clean) {
78
+        if ($clean) {
79 79
             $command = $this->getApplication()->find($clean);
80 80
             $this->cleanJob($command->getName());
81 81
             $output->writeln($command->getName() . " will be executed now");
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
         $lastExec = 0;
100 100
         $hasError = false;
101 101
 
102
-        foreach($jobs as $cmd => $job) {
102
+        foreach ($jobs as $cmd => $job) {
103 103
             $execTime = $job['last_exec'];
104
-            if($execTime > $lastExec) $lastExec = $execTime;
105
-            if(!empty($job['error'])) {
104
+            if ($execTime > $lastExec) $lastExec = $execTime;
105
+            if (!empty($job['error'])) {
106 106
                 $hasError = true;
107 107
             }
108 108
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             'Status',
122 122
         ];
123 123
 
124
-        if($hasError) {
124
+        if ($hasError) {
125 125
             $header[] = 'Error';
126 126
         }
127 127
 
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
         ]);
132 132
 
133 133
         $cnt = 1;
134
-        foreach($jobs as $cmd => $job) {
135
-            if($cnt > 1) $table->addRow(new TableSeparator());
134
+        foreach ($jobs as $cmd => $job) {
135
+            if ($cnt > 1) $table->addRow(new TableSeparator());
136 136
             $row = [
137 137
                 $cmd,
138 138
                 $job['period'],
139 139
                 ($job['last_exec'] ? date("d.m.Y H:i:s", $job['last_exec']) : 'NONE'),
140 140
                 $job['status'],
141 141
             ];
142
-            if($hasError) {
142
+            if ($hasError) {
143 143
                 $row[] = $job['error'];
144 144
             }
145 145
             $table->addRow($row);
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
          */
169 169
         $this->minAgentPeriod = (count($jobs) + 1) * EnvHelper::getBxCrontabPeriod();
170 170
 
171
-        if(!empty($jobs)) {
171
+        if (!empty($jobs)) {
172 172
 
173
-            foreach($jobs as $cmd => $job) {
173
+            foreach ($jobs as $cmd => $job) {
174 174
 
175
-                if($this->isActualJob($job)) {
175
+                if ($this->isActualJob($job)) {
176 176
 
177 177
                     $job['status'] = self::EXEC_STATUS_WORK;
178 178
                     $this->updaateJob($cmd, $job);
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
                         $timeStart = microtime(true);
185 185
                         $returnCode = $command->run($cmdInput, $output);
186 186
 
187
-                        if(!$returnCode) {
187
+                        if (!$returnCode) {
188 188
 
189 189
                             $job['status'] = self::EXEC_STATUS_SUCCESS;
190 190
 
191 191
                             $msg = sprintf("%s: SUCCESS [%.2f s]", $cmd, microtime(true) - $timeStart);
192
-                            if($this->logger) {
192
+                            if ($this->logger) {
193 193
                                 $this->logger->alert($msg);
194 194
                             }
195 195
                             $output->writeln(PHP_EOL . $msg);
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
                             $job['error_code'] = $returnCode;
201 201
 
202 202
                             $msg = sprintf("%s: ERROR [%.2f s]", $cmd, microtime(true) - $timeStart);
203
-                            if($this->logger) {
203
+                            if ($this->logger) {
204 204
                                 $this->logger->alert($msg);
205 205
                             }
206 206
                             $output->writeln(PHP_EOL . $msg);
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                         $job['error'] = $e->getMessage();
213 213
 
214 214
 
215
-                        if($this->logger) {
215
+                        if ($this->logger) {
216 216
                             $this->logger->error($e, ['command' => $cmd]);
217 217
                         }
218 218
                         $output->writeln(PHP_EOL . 'ERROR: ' . $e->getMessage());
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
 
235 235
     protected function isActualJob(&$job) {
236 236
 
237
-        if(isset($job['status']) && $job['status'] !== self::EXEC_STATUS_SUCCESS) {
237
+        if (isset($job['status']) && $job['status'] !== self::EXEC_STATUS_SUCCESS) {
238 238
             return false;
239 239
         }
240 240
 
241 241
         $period = intval($job['period']);
242 242
 
243
-        if($period > 0) {
244
-            if($period < $this->minAgentPeriod) {
243
+        if ($period > 0) {
244
+            if ($period < $this->minAgentPeriod) {
245 245
                 $job['orig_period'] = $period;
246 246
                 $period = $job['period'] = $this->minAgentPeriod;
247 247
             }
248
-            if(time() - $job['last_exec'] >= $period) {
248
+            if (time() - $job['last_exec'] >= $period) {
249 249
                 return true;
250 250
             }
251
-        } else if(!empty($job['times'])) {
251
+        } else if (!empty($job['times'])) {
252 252
             //TODO:
253 253
         }
254 254
 
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
         $commands = $app->all();
264 264
 
265 265
         $selfCommands = [];
266
-        foreach($commands as $command) {
266
+        foreach ($commands as $command) {
267 267
             /** @var BxCommand $command */
268
-            if($command instanceof BxCommand) {
268
+            if ($command instanceof BxCommand) {
269 269
                 $name = $command->getName();
270 270
                 $selfCommands[$name] = [
271 271
                     'object' => $command,
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
 
276 276
         $agents = [];
277 277
         $reader = new AnnotationReader();
278
-        foreach($selfCommands as $cmd => $selfCommand) {
278
+        foreach ($selfCommands as $cmd => $selfCommand) {
279 279
             $reflectionClass = new \ReflectionClass($selfCommand['object']);
280 280
             $annotations = $reader->getClassAnnotations($reflectionClass);
281 281
 
282
-            foreach($annotations as $annotation) {
283
-                if($annotation instanceof Agent) {
282
+            foreach ($annotations as $annotation) {
283
+                if ($annotation instanceof Agent) {
284 284
                     $agents[$cmd] = $annotation->toArray();
285 285
                 }
286 286
             }
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 
289 289
         $crontab = $this->getCronTab();
290 290
 
291
-        foreach($crontab as $cmd => $job) {
292
-            if(is_array($job) && isset($agents[$cmd])) {
291
+        foreach ($crontab as $cmd => $job) {
292
+            if (is_array($job) && isset($agents[$cmd])) {
293 293
                 $agents[$cmd] = array_merge($job, $agents[$cmd]);
294 294
             }
295 295
         }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
         $fh = fopen($filename, 'c');
324 324
         if (flock($fh, LOCK_EX)) {
325 325
             ftruncate($fh, 0);
326
-            if(!fwrite($fh, json_encode($agents, JSON_PRETTY_PRINT))) {
326
+            if (!fwrite($fh, json_encode($agents, JSON_PRETTY_PRINT))) {
327 327
                 throw new \Exception('Unable to write BX_CRONTAB : ' . $filename);
328 328
             }
329 329
         }
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
         $filename = EnvHelper::getCrontabFile();
342 342
 
343 343
         $fh = fopen($filename, 'r');
344
-        if(flock($fh, LOCK_SH)) {
345
-            if($data = @fread($fh, filesize($filename))) {
344
+        if (flock($fh, LOCK_SH)) {
345
+            if ($data = @fread($fh, filesize($filename))) {
346 346
                 $decoded = json_decode($data, true);
347
-                if(is_array($decoded)) {
347
+                if (is_array($decoded)) {
348 348
                     $cronTab = $decoded;
349 349
                 }
350 350
             }
@@ -357,14 +357,14 @@  discard block
 block discarded – undo
357 357
 
358 358
     protected function sortCronTab(array &$crontab, $sort = self::SORT_NAME) {
359 359
 
360
-        if($sort == self::SORT_TIME) {
360
+        if ($sort == self::SORT_TIME) {
361 361
             $sorting = [];
362
-            foreach($crontab as $cmd => $data) {
362
+            foreach ($crontab as $cmd => $data) {
363 363
                 $sorting[$cmd] = $data['last_exec'];
364 364
             }
365 365
             arsort($sorting, SORT_NUMERIC);
366 366
             $sorted = [];
367
-            foreach($sorting as $cmd => $time) {
367
+            foreach ($sorting as $cmd => $time) {
368 368
                 $sorted[$cmd] = $crontab[$cmd];
369 369
             }
370 370
             $crontab = $sorted;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,9 @@  discard block
 block discarded – undo
101 101
 
102 102
         foreach($jobs as $cmd => $job) {
103 103
             $execTime = $job['last_exec'];
104
-            if($execTime > $lastExec) $lastExec = $execTime;
104
+            if($execTime > $lastExec) {
105
+                $lastExec = $execTime;
106
+            }
105 107
             if(!empty($job['error'])) {
106 108
                 $hasError = true;
107 109
             }
@@ -132,7 +134,9 @@  discard block
 block discarded – undo
132 134
 
133 135
         $cnt = 1;
134 136
         foreach($jobs as $cmd => $job) {
135
-            if($cnt > 1) $table->addRow(new TableSeparator());
137
+            if($cnt > 1) {
138
+                $table->addRow(new TableSeparator());
139
+            }
136 140
             $row = [
137 141
                 $cmd,
138 142
                 $job['period'],
Please login to merge, or discard this patch.