| Conditions | 11 |
| Paths | 19 |
| Total Lines | 62 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 102 | $task = $module->instanceTask($info->getTask()); |
||
| 103 | $task->setName($taskName); |
||
| 104 | $task->setSchedule($schedule); |
||
| 105 | for ($i = 4; $i < count($args); $i++) { |
||
| 106 | $parts = explode('=', $args[$i]); |
||
| 107 | $parts[0] = trim($parts[0]); |
||
| 108 | $property = strtolower($parts[0]); |
||
| 109 | if ($task->canSetProperty($property)) { |
||
| 110 | $property = 'set' . $property; |
||
| 111 | $task->$property(trim($parts[1])); |
||
| 112 | } else { |
||
| 113 | $this->_outWriter->writeError("Task Property '{$parts[0]}' is not found"); |
||
| 114 | return true; |
||
| 115 | } |
||
| 116 | } |
||
| 117 | $module->addTask($task); |
||
| 118 | |||
| 119 | $this->_outWriter->writeLine("Task '{$taskName}' was added to the database\n", [TShellWriter::GREEN, TShellWriter::BOLD]); |
||
| 120 | return true; |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * updates a task in the database by its name for its schedule, username, moduleid, and other properties. |
||
| 125 | * @param array $args command arguments |
||
| 126 | */ |
||
| 127 | public function actionUpdate($args) |
||
| 128 | { |
||
| 129 | $module = $this->getCronModule(); |
||
| 130 | if (!($taskName = ($args[1] ?? null))) { |
||
| 131 | $this->_outWriter->writeError("Cannot update a task without a name"); |
||
| 132 | return true; |
||
| 133 | } |
||
| 134 | |||
| 135 | $task = $module->getTask($taskName); |
||
| 136 | if (!$task) { |
||
| 137 | $this->_outWriter->writeError("Task '{$taskName}' is not found"); |
||
| 138 | return true; |
||
| 139 | } |
||
| 140 | if (count($args) < 3) { |
||
| 141 | $this->_outWriter->writeError("No given properties to change"); |
||
| 142 | return true; |
||
| 143 | } |
||
| 144 | for ($i = 2; $i < count($args); $i++) { |
||
| 145 | $parts = explode('=', $args[$i]); |
||
| 146 | $parts[0] = trim($parts[0]); |
||
| 147 | $property = strtolower($parts[0]); |
||
| 148 | if ($task->canSetProperty($property)) { |
||
| 149 | if ($property === 'schedule') { |
||
| 150 | $s = new TTimeScheduler(); |
||
| 151 | try { |
||
| 152 | $s->setSchedule($parts[1]); |
||
| 153 | } catch (TInvalidDataValueException $e) { |
||
| 154 | $this->_outWriter->writeError("Schedule '{$parts[1]}' is not a valid schedule"); |
||
| 155 | return true; |
||
| 156 | } |
||
| 157 | } |
||
| 158 | $property = 'set' . $property; |
||
| 159 | $task->$property(trim($parts[1])); |
||
| 160 | } else { |
||
| 161 | $this->_outWriter->writeError("Task Property '{$parts[0]}' is not found"); |
||
| 162 | return true; |
||
| 163 | } |
||
| 164 | } |
||
| 196 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths