Conditions | 9 |
Paths | 17 |
Total Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
49 | public function runQueue($queue) |
||
50 | { |
||
51 | // check if queue can be processed |
||
52 | $service = QueuedJobService::singleton(); |
||
53 | if ($service->isAtMaxJobs()) { |
||
54 | $service->getLogger()->info('Not processing queue as jobs are at max initialisation limit.'); |
||
55 | return; |
||
56 | } |
||
57 | |||
58 | // split jobs out into multiple tasks... |
||
59 | |||
60 | /** @var ProcessManager $manager */ |
||
61 | $manager = Injector::inst()->create(ProcessManager::class); |
||
62 | $manager->setWorker( |
||
63 | BASE_PATH . "/vendor/silverstripe/framework/cli-script.php dev/tasks/ProcessJobQueueChildTask" |
||
64 | ); |
||
65 | $logPath = Environment::getEnv('SS_DOORMAN_LOGPATH'); |
||
|
|||
66 | if ($logPath) { |
||
67 | $manager->setLogPath($logPath); |
||
68 | } |
||
69 | |||
70 | // Assign default rules |
||
71 | $defaultRules = $this->getDefaultRules(); |
||
72 | if ($defaultRules) { |
||
73 | foreach ($defaultRules as $rule) { |
||
74 | $manager->addRule($rule); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | $descriptor = $this->getNextJobDescriptorWithoutMutex($queue); |
||
79 | |||
80 | while ($manager->tick() || $descriptor) { |
||
81 | if (QueuedJobService::singleton()->isMaintenanceLockActive()) { |
||
82 | $service->getLogger()->info('Skipped queued job descriptor since maintenance log is active.'); |
||
83 | return; |
||
84 | } |
||
85 | |||
86 | $this->logDescriptorStatus($descriptor, $queue); |
||
87 | |||
88 | if ($descriptor instanceof QueuedJobDescriptor) { |
||
89 | $descriptor->JobStatus = QueuedJob::STATUS_INIT; |
||
90 | $descriptor->write(); |
||
91 | |||
92 | $manager->addTask(new DoormanQueuedJobTask($descriptor)); |
||
93 | } |
||
94 | |||
95 | sleep(1); |
||
96 | |||
97 | $descriptor = $this->getNextJobDescriptorWithoutMutex($queue); |
||
98 | } |
||
99 | } |
||
100 | |||
128 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.