| Conditions | 13 |
| Paths | 1026 |
| Total Lines | 44 |
| Code Lines | 27 |
| 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 |
||
| 79 | private function sync_task_user($data) { |
||
| 80 | $id = $data->externalId ?? null; |
||
| 81 | if (!$id) { |
||
| 82 | return null; |
||
| 83 | } |
||
| 84 | |||
| 85 | $submission = $this->repository->get_by_id($id); |
||
| 86 | |||
| 87 | if (!$submission) { |
||
| 88 | return null; |
||
| 89 | } |
||
| 90 | |||
| 91 | $submission->status = 1; |
||
| 92 | $submission->error = ''; |
||
| 93 | |||
| 94 | if (isset($data->title)) { |
||
| 95 | $submission->title = $data->title; |
||
| 96 | } |
||
| 97 | if (isset($data->content)) { |
||
| 98 | $submission->content = $data->content; |
||
| 99 | } |
||
| 100 | if (isset($data->url)) { |
||
| 101 | $submission->url = $data->url; |
||
| 102 | } |
||
| 103 | if (isset($data->authKey)) { |
||
| 104 | $submission->authkey = $data->authKey; |
||
| 105 | } |
||
| 106 | if (isset($data->score)) { |
||
| 107 | $submission->score = $data->score; |
||
| 108 | } |
||
| 109 | if (isset($data->plagiarism)) { |
||
| 110 | $submission->plagiarism = $data->plagiarism; |
||
| 111 | } |
||
| 112 | if (isset($data->aiAverageProbability)) { |
||
| 113 | $submission->airate = $data->aiAverageProbability; |
||
| 114 | } |
||
| 115 | if (isset($data->aiProbability)) { |
||
| 116 | $submission->aiprobability = $data->aiProbability; |
||
| 117 | } |
||
| 118 | if (isset($data->loginTimeToken)) { |
||
| 119 | $submission->userkey = $data->loginTimeToken; |
||
| 120 | } |
||
| 121 | |||
| 122 | return $this->repository->update_submission($submission) ? $submission->id : null; |
||
| 123 | } |
||
| 125 |