| Conditions | 7 |
| Paths | 64 |
| Total Lines | 68 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 2 | ||
| Bugs | 1 | 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 |
||
| 15 | public function run() |
||
| 16 | { |
||
| 17 | try { |
||
| 18 | factory(Module::class)->create( |
||
| 19 | [ |
||
| 20 | "name" => "MP01 - Implantació de sistemes operatius(ASIX) - Implementació de sistemes informàtics(DAM)", |
||
| 21 | "order" => 1, |
||
| 22 | "study_id" => 1 |
||
| 23 | |||
| 24 | ] |
||
| 25 | ); |
||
| 26 | } catch (\Illuminate\Database\QueryException $exception) { |
||
|
|
|||
| 27 | } |
||
| 28 | try { |
||
| 29 | factory(Module::class)->create( |
||
| 30 | [ |
||
| 31 | "name" => "MP02 - Gestió de bases de dades", |
||
| 32 | "order" => 2, |
||
| 33 | "study_id" => 1 |
||
| 34 | ] |
||
| 35 | ); |
||
| 36 | } catch (\Illuminate\Database\QueryException $exception) { |
||
| 37 | } |
||
| 38 | |||
| 39 | try { |
||
| 40 | factory(Module::class)->create( |
||
| 41 | [ |
||
| 42 | "name" => "MP03 - Programació bàsica", |
||
| 43 | "order" => 3, |
||
| 44 | "study_id" => 1 |
||
| 45 | ] |
||
| 46 | ); |
||
| 47 | } catch (\Illuminate\Database\QueryException $exception) { |
||
| 48 | } |
||
| 49 | |||
| 50 | try { |
||
| 51 | factory(Module::class)->create( |
||
| 52 | [ |
||
| 53 | "name" => "MP04 - Llenguatges de marques i sistemes de gestió d'informació", |
||
| 54 | "order" => 4, |
||
| 55 | "study_id" => 1 |
||
| 56 | ] |
||
| 57 | ); |
||
| 58 | } catch (\Illuminate\Database\QueryException $exception) { |
||
| 59 | } |
||
| 60 | |||
| 61 | try { |
||
| 62 | factory(Module::class)->create( |
||
| 63 | [ |
||
| 64 | "name" => "MP01 - Module 1", |
||
| 65 | "order" => 1, |
||
| 66 | "study_id" => 2 |
||
| 67 | ] |
||
| 68 | ); |
||
| 69 | } catch (\Illuminate\Database\QueryException $exception) { |
||
| 70 | } |
||
| 71 | |||
| 72 | try { |
||
| 73 | factory(Module::class)->create( |
||
| 74 | [ |
||
| 75 | "name" => "MP02 - Module 2", |
||
| 76 | "order" => 2, |
||
| 77 | "study_id" => 2 |
||
| 78 | ] |
||
| 79 | ); |
||
| 80 | } catch (\Illuminate\Database\QueryException $exception) { |
||
| 81 | } |
||
| 82 | } |
||
| 83 | } |
||
| 84 |