@@ -10,7 +10,7 @@ discard block |
||
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 |
||
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 |
@@ -47,7 +47,7 @@ |
||
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); |
@@ -25,8 +25,8 @@ discard block |
||
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 |
||
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); |
@@ -18,10 +18,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -10,15 +10,15 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -16,9 +16,15 @@ |
||
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 | /** |
@@ -29,37 +29,37 @@ discard block |
||
29 | 29 | protected function execute(InputInterface $input, OutputInterface $output) |
30 | 30 | { |
31 | 31 | $logger = EnvHelper::getLogger('bx_cron'); |
32 | - if($logger) { |
|
32 | + if ($logger) { |
|
33 | 33 | $this->setLogger($logger); |
34 | 34 | } |
35 | 35 | |
36 | - if(EnvHelper::getSwitch('BX_CRONTAB_RUN', EnvHelper::SWITCH_STATE_OFF)) { |
|
37 | - if($this->logger) { |
|
36 | + if (EnvHelper::getSwitch('BX_CRONTAB_RUN', EnvHelper::SWITCH_STATE_OFF)) { |
|
37 | + if ($this->logger) { |
|
38 | 38 | $this->logger->alert('BxCron switch off'); |
39 | 39 | } |
40 | 40 | return 0; |
41 | 41 | } |
42 | 42 | |
43 | - if(!$this->lock()) { |
|
43 | + if (!$this->lock()) { |
|
44 | 44 | $msg = 'The command is already running in another process.'; |
45 | 45 | $output->writeln($msg); |
46 | - if($this->logger) { |
|
46 | + if ($this->logger) { |
|
47 | 47 | $this->logger->warning($msg); |
48 | 48 | } |
49 | 49 | return 0; |
50 | 50 | } |
51 | 51 | |
52 | - if($sleepInterval = EnvHelper::checkSleepInterval()) { |
|
52 | + if ($sleepInterval = EnvHelper::checkSleepInterval()) { |
|
53 | 53 | $msg = sprintf("Sleep in interval %s", $sleepInterval); |
54 | 54 | $output->writeln($msg); |
55 | - if($this->logger) { |
|
55 | + if ($this->logger) { |
|
56 | 56 | $this->logger->warning($msg); |
57 | 57 | } |
58 | 58 | return 0; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $clean = $input->getOption('clean'); |
62 | - if($clean) { |
|
62 | + if ($clean) { |
|
63 | 63 | $command = $this->getApplication()->find($clean); |
64 | 64 | $this->cleanJob($command->getName()); |
65 | 65 | $output->writeln($command->getName() . " will be executed now"); |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | */ |
91 | 91 | $this->minAgentPeriod = (count($jobs) + 1) * EnvHelper::getBxCrontabPeriod(); |
92 | 92 | |
93 | - if(!empty($jobs)) { |
|
93 | + if (!empty($jobs)) { |
|
94 | 94 | |
95 | - foreach($jobs as $cmd => $job) { |
|
95 | + foreach ($jobs as $cmd => $job) { |
|
96 | 96 | |
97 | - if($this->isActualJob($job)) { |
|
97 | + if ($this->isActualJob($job)) { |
|
98 | 98 | |
99 | 99 | $job['status'] = self::EXEC_STATUS_WORK; |
100 | 100 | $this->updaateJob($cmd, $job); |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | $timeStart = microtime(true); |
107 | 107 | $returnCode = $command->run($cmdInput, $output); |
108 | 108 | |
109 | - if(!$returnCode) { |
|
109 | + if (!$returnCode) { |
|
110 | 110 | |
111 | 111 | $job['status'] = self::EXEC_STATUS_SUCCESS; |
112 | 112 | |
113 | 113 | $msg = sprintf("%s: SUCCESS [%.2f s]", $cmd, microtime(true) - $timeStart); |
114 | - if($this->logger) { |
|
114 | + if ($this->logger) { |
|
115 | 115 | $this->logger->alert($msg); |
116 | 116 | } |
117 | 117 | $output->writeln(PHP_EOL . $msg); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $job['error_code'] = $returnCode; |
123 | 123 | |
124 | 124 | $msg = sprintf("%s: ERROR [%.2f s]", $cmd, microtime(true) - $timeStart); |
125 | - if($this->logger) { |
|
125 | + if ($this->logger) { |
|
126 | 126 | $this->logger->alert($msg); |
127 | 127 | } |
128 | 128 | $output->writeln(PHP_EOL . $msg); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $job['error'] = $e->getMessage(); |
135 | 135 | |
136 | 136 | |
137 | - if($this->logger) { |
|
137 | + if ($this->logger) { |
|
138 | 138 | $this->logger->error($e, ['command' => $cmd]); |
139 | 139 | } |
140 | 140 | $output->writeln(PHP_EOL . 'ERROR: ' . $e->getMessage()); |
@@ -158,21 +158,21 @@ discard block |
||
158 | 158 | |
159 | 159 | protected function isActualJob(&$job) { |
160 | 160 | |
161 | - if(isset($job['status']) && $job['status'] !== self::EXEC_STATUS_SUCCESS) { |
|
161 | + if (isset($job['status']) && $job['status'] !== self::EXEC_STATUS_SUCCESS) { |
|
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $period = intval($job['period']); |
166 | 166 | |
167 | - if($period > 0) { |
|
168 | - if($period < $this->minAgentPeriod) { |
|
167 | + if ($period > 0) { |
|
168 | + if ($period < $this->minAgentPeriod) { |
|
169 | 169 | $job['orig_period'] = $period; |
170 | 170 | $period = $job['period'] = $this->minAgentPeriod; |
171 | 171 | } |
172 | - if(time() - $job['last_exec'] >= $period) { |
|
172 | + if (time() - $job['last_exec'] >= $period) { |
|
173 | 173 | return true; |
174 | 174 | } |
175 | - } else if(!empty($job['times'])) { |
|
175 | + } else if (!empty($job['times'])) { |
|
176 | 176 | //TODO: |
177 | 177 | } |
178 | 178 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | $commands = $app->all(); |
188 | 188 | |
189 | 189 | $selfCommands = []; |
190 | - foreach($commands as $command) { |
|
190 | + foreach ($commands as $command) { |
|
191 | 191 | /** @var BxCommand $command */ |
192 | - if($command instanceof BxCommand) { |
|
192 | + if ($command instanceof BxCommand) { |
|
193 | 193 | $name = $command->getName(); |
194 | 194 | $selfCommands[$name] = [ |
195 | 195 | 'object' => $command, |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | |
200 | 200 | $agents = []; |
201 | 201 | $reader = new AnnotationReader(); |
202 | - foreach($selfCommands as $cmd => $selfCommand) { |
|
202 | + foreach ($selfCommands as $cmd => $selfCommand) { |
|
203 | 203 | $reflectionClass = new \ReflectionClass($selfCommand['object']); |
204 | 204 | $annotations = $reader->getClassAnnotations($reflectionClass); |
205 | 205 | |
206 | - foreach($annotations as $annotation) { |
|
207 | - if($annotation instanceof Agent) { |
|
206 | + foreach ($annotations as $annotation) { |
|
207 | + if ($annotation instanceof Agent) { |
|
208 | 208 | $agents[$cmd] = $annotation->toArray(); |
209 | 209 | } |
210 | 210 | } |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | |
213 | 213 | $crontab = $this->getCronTab(); |
214 | 214 | |
215 | - foreach($crontab as $cmd => $job) { |
|
216 | - if(is_array($job) && isset($agents[$cmd])) { |
|
215 | + foreach ($crontab as $cmd => $job) { |
|
216 | + if (is_array($job) && isset($agents[$cmd])) { |
|
217 | 217 | $agents[$cmd] = array_merge($job, $agents[$cmd]); |
218 | 218 | } |
219 | 219 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | $fh = fopen($filename, 'c'); |
246 | 246 | if (flock($fh, LOCK_EX)) { |
247 | 247 | ftruncate($fh, 0); |
248 | - if(!fwrite($fh, json_encode($agents, JSON_PRETTY_PRINT))) { |
|
248 | + if (!fwrite($fh, json_encode($agents, JSON_PRETTY_PRINT))) { |
|
249 | 249 | throw new \Exception('Unable to write BX_CRONTAB : ' . $filename); |
250 | 250 | } |
251 | 251 | } |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | $filename = EnvHelper::getCrontabFile(); |
264 | 264 | |
265 | 265 | $fh = fopen($filename, 'r'); |
266 | - if(flock($fh, LOCK_SH)) { |
|
267 | - if($data = @fread($fh, filesize($filename))) { |
|
266 | + if (flock($fh, LOCK_SH)) { |
|
267 | + if ($data = @fread($fh, filesize($filename))) { |
|
268 | 268 | $decoded = json_decode($data, true); |
269 | - if(is_array($decoded)) { |
|
269 | + if (is_array($decoded)) { |
|
270 | 270 | $cronTab = $decoded; |
271 | 271 | } |
272 | 272 | } |