Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 7 | ||
Bugs | 1 | Features | 2 |
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 |
||
30 | protected function setUp() |
||
31 | { |
||
32 | $placesCollector = new PlacesCollector(); |
||
33 | $placesCollector->addBasePlaceTypes(); |
||
34 | |||
35 | /** @var Location $locationType */ |
||
36 | $locationType = $placesCollector->getPlaceTypeByClass(Location::class); |
||
37 | /** @var Corridor $locationType */ |
||
38 | $corridorType = $placesCollector->getPlaceTypeByClass(Corridor::class); |
||
39 | /** @var Wall $locationType */ |
||
40 | $wallType = $placesCollector->getPlaceTypeByClass(Wall::class); |
||
41 | |||
42 | $loc1 = new Place($locationType, 'L1'); |
||
43 | $loc2 = new Place($locationType, 'L2'); |
||
44 | $loc3 = new Place($locationType, 'L3'); |
||
45 | $loc4 = new Place($locationType, 'L4'); |
||
46 | $loc5 = new Place($locationType, 'L5'); |
||
47 | $loc6 = new Place($locationType, 'L6'); |
||
48 | $loc7 = new Place($locationType, 'L7'); |
||
49 | $loc8 = new Place($locationType, 'L8'); |
||
50 | $corr1 = new Place($corridorType, 'C1'); |
||
51 | $wall1 = new Place($wallType, 'W1'); |
||
52 | $wall2 = new Place($wallType, 'W2'); |
||
53 | |||
54 | $loc1->setRightRef($wall1); |
||
55 | $loc1->setBottomRef($loc2); |
||
56 | |||
57 | $loc2->setRightRef($wall2); |
||
58 | $loc2->setBottomRef($loc3); |
||
59 | |||
60 | $loc3->setRightRef($corr1); |
||
61 | |||
62 | $wall1->setBottomRef($wall2); |
||
63 | $wall1->setRightRef($loc6); |
||
64 | |||
65 | $wall2->setBottomRef($corr1); |
||
66 | $wall2->setRightRef($loc5); |
||
67 | |||
68 | $corr1->setRightRef($loc4); |
||
69 | $loc6->setBottomRef($loc5); |
||
70 | $loc6->setRightRef($loc7); |
||
71 | $loc5->setBottomRef($loc4); |
||
72 | $loc5->setRightRef($loc8); |
||
73 | |||
74 | $loc7->setBottomRef($loc8); |
||
75 | |||
76 | $arrayPlaces = array($loc1, $loc2, $loc3, $loc4, $loc5, $loc6, $loc7, $loc8, $corr1, $wall1, $wall2); |
||
77 | |||
78 | $wm = new TreeParser($arrayPlaces, $placesCollector); |
||
79 | $placesCollector->setPlaces($wm->parse()); |
||
80 | |||
81 | $breadcrumbBuilder = new BreadthFirstBreadcrumb($placesCollector); |
||
82 | |||
83 | $this->warehouse = new Warehouse($placesCollector, $wm, $breadcrumbBuilder); |
||
84 | } |
||
123 | } |