@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | protected function controllerIsSetup() { |
84 | 84 | $this->log('Check if controllerIsSetup'); |
85 | 85 | |
86 | - if(!is_null($this->crawler_id)) { |
|
86 | + if (!is_null($this->crawler_id)) { |
|
87 | 87 | return true; |
88 | 88 | } |
89 | 89 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | $this->log('Setup crawler'); |
101 | 101 | |
102 | - if(!is_null($crawler_id)) { |
|
102 | + if (!is_null($crawler_id)) { |
|
103 | 103 | $this->log('Setup crawler, crawler_id is not set'); |
104 | 104 | $this->setCrawlerId($crawler_id); |
105 | 105 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $this->log('Checking if crawler is enabled'); |
115 | 115 | if (!$this->crawler->enabled) { |
116 | 116 | $this->log('Crawler is not enabled'); |
117 | - throw new CrawlerException('Crawler (#' . $this->crawler_id . ') - crawler isnt enabled in database'); |
|
117 | + throw new CrawlerException('Crawler (#'.$this->crawler_id.') - crawler isnt enabled in database'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->log('Checking if crawler can be runned'); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | |
140 | 140 | if ($this->crawler->latest_status == 3) { |
141 | - if($this->override_fail_status) { |
|
141 | + if ($this->override_fail_status) { |
|
142 | 142 | $this->log('Last crawler failed, but it is forced to run'); |
143 | 143 | |
144 | 144 | //override the failed state, this will force to rerun... |
@@ -146,16 +146,16 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | $this->log('Last crawler failed, force run is not enabled'); |
149 | - throw new CrawlerException('Crawler (#' . $this->crawler_id . ') - last run had an error and override_fail_status is not enabled'); |
|
149 | + throw new CrawlerException('Crawler (#'.$this->crawler_id.') - last run had an error and override_fail_status is not enabled'); |
|
150 | 150 | } |
151 | 151 | } else { |
152 | 152 | $this->log('Crawler needs to wait ('.$checkIfCrawlerCanBeRunned['retry_in'].' seconds) before running again'); |
153 | - throw new CrawlerNotReachedTimeBetweenJobsException('Has to wait ' . $checkIfCrawlerCanBeRunned['retry_in'] . ' more seconds to run'); |
|
153 | + throw new CrawlerNotReachedTimeBetweenJobsException('Has to wait '.$checkIfCrawlerCanBeRunned['retry_in'].' more seconds to run'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if ($x == $times) { |
157 | 157 | $this->log('Crawler exceeded the max execution time'); |
158 | - $this->failCrawler('Crawler (#' . $this->crawler_id . ') - max execution time'); |
|
158 | + $this->failCrawler('Crawler (#'.$this->crawler_id.') - max execution time'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | if ($this->crawler->status == 1) { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | CrawlerStatusLogs::insert($formatted_logs); |
262 | 262 | } |
263 | 263 | |
264 | - if($status == 2) { |
|
264 | + if ($status == 2) { |
|
265 | 265 | $this->stopLogging($crawlerstatus->id); |
266 | 266 | } |
267 | 267 | |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | protected function saveLog($crawlerstatus_id) { |
276 | 276 | $formatted_logs = []; |
277 | 277 | |
278 | - foreach($this->logs as $log) { |
|
278 | + foreach ($this->logs as $log) { |
|
279 | 279 | $formatted_logs[] = [ |
280 | 280 | 'status_id' => $crawlerstatus_id, |
281 | 281 | 'output' => $log |
282 | 282 | ]; |
283 | 283 | } |
284 | - if(count($formatted_logs) > 0) { |
|
284 | + if (count($formatted_logs) > 0) { |
|
285 | 285 | $this->log('Registering crawler logs'); |
286 | 286 | |
287 | 287 | CrawlerStatusLogs::insert($formatted_logs); |
288 | 288 | |
289 | - $this->log('Registered crawler logs (count: ' . count($formatted_logs) . ')'); |
|
289 | + $this->log('Registered crawler logs (count: '.count($formatted_logs).')'); |
|
290 | 290 | } else { |
291 | 291 | $this->log('Log output is not set, skipping inserting'); |
292 | 292 | } |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | $this->log('Stop logging'); |
349 | 349 | $this->logging = false; |
350 | 350 | |
351 | - if(!is_null($crawlerstatus_id)) { |
|
351 | + if (!is_null($crawlerstatus_id)) { |
|
352 | 352 | $this->saveLog($crawlerstatus_id); |
353 | 353 | } |
354 | 354 | } |
355 | 355 | protected function log($item = '') |
356 | 356 | { |
357 | - if($this->logging) |
|
357 | + if ($this->logging) |
|
358 | 358 | { |
359 | 359 | $log = $item.' (crawler_id: '.$this->crawler_id.')'; |
360 | 360 |