Conditions | 1 |
Paths | 1 |
Total Lines | 12 |
Code Lines | 4 |
Lines | 12 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
18 | protected function askForUsers() |
||
19 | { |
||
20 | $users = User::all(); |
||
21 | |||
22 | //pluck és com si es fes un foreach buscant per nom i afegir-ho a un array. |
||
23 | //el que fa es agafar el valor a partir d'una clau. |
||
24 | // ho passem a array i ho mostrem. |
||
25 | // + info README |
||
26 | $user_names = $users->pluck('name')->toArray(); |
||
27 | $user_name = $this->choice('User id?', $user_names); |
||
28 | |||
29 | return $users->where('name', $user_name)->first()->id; |
||
30 | } |
||
32 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.