| Conditions | 5 |
| Paths | 5 |
| Total Lines | 57 |
| Code Lines | 33 |
| 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 |
||
| 53 | protected function processLoan(Loan $loan) |
||
| 54 | { |
||
| 55 | $barcode = $loan->item->barcode; |
||
| 56 | $library = $loan->library; |
||
| 57 | |||
| 58 | echo " - $barcode: "; |
||
| 59 | |||
| 60 | $errBecause = sprintf( |
||
| 61 | 'Kunne ikke sjekke lån av <a href="%s">%s</a> mot Alma fordi', |
||
| 62 | action('ItemsController@show', $loan->item_id), |
||
| 63 | $barcode |
||
| 64 | ); |
||
| 65 | |||
| 66 | $sucBecause = sprintf( |
||
| 67 | 'Fjerner lokalt lån av <a href="%s">%s</a> fordi', |
||
| 68 | action('ItemsController@show', $loan->item_id), |
||
| 69 | $barcode |
||
| 70 | ); |
||
| 71 | |||
| 72 | if (is_null($library->temporary_barcode)) { |
||
| 73 | $this->line('konfigfeil'); |
||
| 74 | \Log::error("$errBecause biblioteket ikke lenger har et midlertidig lånekort."); |
||
| 75 | return; |
||
| 76 | } |
||
| 77 | |||
| 78 | $tempUser = $this->alma->users[$library->temporary_barcode]; |
||
| 79 | |||
| 80 | if (is_null($tempUser)) { |
||
| 81 | $this->line('konfigfeil'); |
||
| 82 | \Log::error("$errBecause brukeren '{$library->temporary_barcode}' ikke ble funnet i Alma."); |
||
| 83 | return; |
||
| 84 | } |
||
| 85 | |||
| 86 | $almaItem = $this->alma->items->fromBarcode($barcode); |
||
| 87 | $almaLoan = $almaItem->loan; |
||
| 88 | |||
| 89 | if (is_null($almaLoan)) { |
||
| 90 | $this->line('returnert i Alma'); |
||
| 91 | |||
| 92 | // Delete local loan and item |
||
| 93 | $loan->checkIn(); |
||
| 94 | |||
| 95 | \Log::info("$sucBecause dokumentet har blitt returnert i Alma."); |
||
| 96 | return; |
||
| 97 | } |
||
| 98 | |||
| 99 | if ($almaLoan->user_id != $library->temporary_barcode) { |
||
| 100 | $this->line('utlånt til annen person i Alma'); |
||
| 101 | |||
| 102 | // Delete local loan and item |
||
| 103 | $loan->checkIn(); |
||
| 104 | |||
| 105 | \Log::info("$sucBecause dokumentet har blitt utlånt til en annen person i Alma."); |
||
| 106 | return; |
||
| 107 | } |
||
| 108 | |||
| 109 | $this->line('fremdeles utlånt i Alma'); |
||
| 110 | } |
||
| 112 |
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