Conditions | 2 |
Paths | 2 |
Total Lines | 104 |
Code Lines | 4 |
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 |
||
15 | public function run() |
||
16 | { |
||
17 | $locations = '[ |
||
18 | { |
||
19 | "_key":"dragonstone", |
||
20 | "name":"Dragonstone", |
||
21 | "coordinate":[ |
||
22 | 55.167801, |
||
23 | -6.815096 |
||
24 | ], |
||
25 | "led_by":"DaenerysTargaryen", |
||
26 | "capturable_id":"DaenerysTargaryen", |
||
27 | "capturable_type": "TestSetup\\\Models\\\Character" |
||
28 | }, |
||
29 | { |
||
30 | "_key":"king-s-landing", |
||
31 | "name":"King\'s Landing", |
||
32 | "coordinate":[ |
||
33 | 42.639752, |
||
34 | 18.110189 |
||
35 | ], |
||
36 | "led_by":"CerseiLannister", |
||
37 | "capturable_id":"DaenerysTargaryen", |
||
38 | "capturable_type": "TestSetup\\\Models\\\Character" |
||
39 | }, |
||
40 | { |
||
41 | "_key":"the-red-keep", |
||
42 | "name":"The Red Keep", |
||
43 | "coordinate":[ |
||
44 | 35.896447, |
||
45 | 14.446442 |
||
46 | ], |
||
47 | "led_by":"CerseiLannister", |
||
48 | "capturable_id":"DaenerysTargaryen", |
||
49 | "capturable_type": "TestSetup\\\Models\\\Character" |
||
50 | |||
51 | }, |
||
52 | { |
||
53 | "_key":"yunkai", |
||
54 | "name":"Yunkai", |
||
55 | "coordinate":[ |
||
56 | 31.046642, |
||
57 | -7.129532 |
||
58 | ], |
||
59 | "led_by":"DaenerysTargaryen", |
||
60 | "capturable_id":"DaenerysTargaryen", |
||
61 | "capturable_type": "TestSetup\\\Models\\\Character" |
||
62 | |||
63 | }, |
||
64 | { |
||
65 | "_key":"astapor", |
||
66 | "name":"Astapor", |
||
67 | "coordinate":[ |
||
68 | 31.50974, |
||
69 | -9.774249 |
||
70 | ], |
||
71 | "led_by":"DaenerysTargaryen", |
||
72 | "capturable_id":"DaenerysTargaryen", |
||
73 | "capturable_type": "TestSetup\\\Models\\\Character" |
||
74 | |||
75 | }, |
||
76 | { |
||
77 | "_key":"winterfell", |
||
78 | "name":"Winterfell", |
||
79 | "coordinate":[ |
||
80 | 54.368321, |
||
81 | -5.581312 |
||
82 | ], |
||
83 | "led_by":"SansaStark", |
||
84 | "capturable_id":"TheonGreyjoy", |
||
85 | "capturable_type": "TestSetup\\\Models\\\Character" |
||
86 | |||
87 | }, |
||
88 | { |
||
89 | "_key":"vaes-dothrak", |
||
90 | "name":"Vaes Dothrak", |
||
91 | "coordinate":[ |
||
92 | 54.16776, |
||
93 | -6.096125 |
||
94 | ], |
||
95 | "led_by":"DaenerysTargaryen" |
||
96 | }, |
||
97 | { |
||
98 | "_key":"beyond-the-wall", |
||
99 | "name":"Beyond the wall", |
||
100 | "coordinate":[ |
||
101 | 64.265473, |
||
102 | -21.094093 |
||
103 | ] |
||
104 | }, |
||
105 | { |
||
106 | "_key":"riverrun", |
||
107 | "name":"Riverrun", |
||
108 | "coordinate":[ |
||
109 | 54.311011, |
||
110 | -6.5214502 |
||
111 | ] |
||
112 | } |
||
113 | ]'; |
||
114 | |||
115 | $locations = json_decode($locations, JSON_OBJECT_AS_ARRAY); |
||
|
|||
116 | |||
117 | foreach ($locations as $location) { |
||
118 | Location::insertOrIgnore($location); |
||
119 | } |
||
122 |