| Conditions | 8 |
| Paths | 20 |
| Total Lines | 62 |
| Code Lines | 43 |
| 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 |
||
| 47 | protected function processUser(User $user) |
||
| 48 | { |
||
| 49 | echo " - $user->name: "; |
||
| 50 | |||
| 51 | if ($user->in_alma) { |
||
| 52 | if ($user->updateFromAlma($this->alma)) { |
||
| 53 | if ($user->isDirty()) { |
||
| 54 | \Log::info(sprintf( |
||
| 55 | 'Oppdaterte brukeren <a href="%s">%s</a> fra Alma.', |
||
| 56 | action('UsersController@getShow', $user->id), |
||
| 57 | $user->name |
||
| 58 | )); |
||
| 59 | |||
| 60 | $this->info('oppdatert'); |
||
| 61 | } else { |
||
| 62 | $this->line('ingen endringer'); |
||
| 63 | } |
||
| 64 | } else { |
||
| 65 | \Log::warning(sprintf( |
||
| 66 | 'Brukeren <a href="%s">%s</a> ble ikke lenger funnet i Alma!', |
||
| 67 | action('UsersController@getShow', $user->id), |
||
| 68 | $user->name |
||
| 69 | )); |
||
| 70 | |||
| 71 | $this->warn('ikke i Alma lenger'); |
||
| 72 | } |
||
| 73 | } else { |
||
| 74 | if ($user->updateFromAlma($this->alma)) { |
||
| 75 | \Log::info(sprintf( |
||
| 76 | 'Lenket brukeren <a href="%s">%s</a> til en Alma-bruker.', |
||
| 77 | action('UsersController@getShow', $user->id), |
||
| 78 | $user->name |
||
| 79 | )); |
||
| 80 | |||
| 81 | $this->info('lenket til Alma-bruker'); |
||
| 82 | $this->transferLoans($user); |
||
| 83 | } else { |
||
| 84 | $this->line('ikke i Alma'); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | try { |
||
| 88 | $user->save(); |
||
| 89 | } catch (PDOException $e) { |
||
| 90 | $this->error('Konflikt!'); |
||
| 91 | \Log::warning(sprintf( |
||
| 92 | 'Brukeren <a href="%s">%s</a> kunne ikke lagres på grunn av en konflikt - to brukere har ' . |
||
| 93 | 'samme strekkode eller feide-id. Sjekk i brukerlista om det er to brukere som kan slås sammen.', |
||
| 94 | action('UsersController@getShow', $user->id), |
||
| 95 | $user->name |
||
| 96 | )); |
||
| 97 | return; |
||
| 98 | } |
||
| 99 | |||
| 100 | if ($user->in_alma) { |
||
| 101 | // Check if user have loans of thing_id 1 and transfer them if so. |
||
| 102 | // In case the user was manually synced during the day. |
||
| 103 | $tempLoans = $user->loans()->whereHas('item', function ($query) { |
||
| 104 | $query->where('thing_id', 1); |
||
| 105 | })->count(); |
||
| 106 | |||
| 107 | if ($tempLoans) { |
||
| 108 | $this->transferLoans($user); |
||
| 109 | } |
||
| 199 |
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