Conditions | 4 |
Paths | 4 |
Total Lines | 26 |
Code Lines | 11 |
Lines | 13 |
Ratio | 50 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
48 | public function actionWatch() |
||
49 | { |
||
50 | Craft::log(Craft::t('Watching for new tasks.')); |
||
51 | |||
52 | // Keep on checking for pending tasks |
||
53 | while (true) { |
||
54 | |||
55 | // Make sure tasks aren't already running |
||
56 | View Code Duplication | if (!craft()->tasks->isTaskRunning()) { |
|
1 ignored issue
–
show
|
|||
57 | |||
58 | // Is there a pending task? |
||
59 | if (craft()->tasks->getNextPendingTask()) { |
||
60 | |||
61 | // Start running tasks |
||
62 | craft()->tasks->runPendingTasks(); |
||
63 | } else { |
||
64 | Craft::log(Craft::t('No pending tasks found.')); |
||
65 | } |
||
66 | } else { |
||
67 | Craft::log(Craft::t('Tasks are already running, skipping iteration.')); |
||
68 | } |
||
69 | |||
70 | // Sleep a little |
||
71 | sleep(10); |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.