Conditions | 16 |
Paths | 16386 |
Total Lines | 68 |
Code Lines | 51 |
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 |
||
63 | public function requireDefaultRecords() |
||
64 | { |
||
65 | parent::requireDefaultRecords(); |
||
66 | $update = array(); |
||
67 | $page = DataObject::get_one("WishListPage"); |
||
68 | if (!$page) { |
||
69 | $page = new WishListPage(); |
||
70 | $page->Title = "Wish List"; |
||
71 | $page->MetaTitle = "Wish List"; |
||
72 | $page->URLSegment = "wish-list"; |
||
73 | $page->MenuTitle = "wish list"; |
||
74 | } |
||
75 | if ($page) { |
||
76 | if (!$page->AddedToListText) { |
||
77 | $page->AddedToListText = "added to wish list"; |
||
78 | $update[] ="updated AddedToListText"; |
||
79 | } |
||
80 | if (!$page->AddedToListTextError) { |
||
81 | $page->AddedToListTextError = "could not add to wish list"; |
||
82 | $update[] ="updated AddedToListTextError"; |
||
83 | } |
||
84 | if (!$page->RemovedFromListConfirmation) { |
||
85 | $page->RemovedFromListConfirmation = "are you sure you want to remove it from your wish list?"; |
||
86 | $update[] ="updated RemovedFromListConfirmation"; |
||
87 | } |
||
88 | if (!$page->RetrieveListConfirmation) { |
||
89 | $page->RetrieveListConfirmation = "Are you sure you would like to retrieve your saved list? It will replace your current list. Do you want to go ahead?"; |
||
90 | $update[] ="updated RetrieveListConfirmation"; |
||
91 | } |
||
92 | if (!$page->ClearListConfirmation) { |
||
93 | $page->ClearListConfirmation = "Are you sure you would like to clear your saved list? "; |
||
94 | $update[] ="updated ClearListConfirmation"; |
||
95 | } |
||
96 | if (!$page->RemovedFromListText) { |
||
97 | $page->RemovedFromListText = "removed from wish list"; |
||
98 | $update[] ="updated RemovedFromListText"; |
||
99 | } |
||
100 | if (!$page->RemovedFromListTextError) { |
||
101 | $page->RemovedFromListTextError = "could not be removed from wish list"; |
||
102 | $update[] ="updated RemovedFromListTextError"; |
||
103 | } |
||
104 | if (!$page->ClearWishList) { |
||
105 | $page->ClearWishList = "cleared wish list"; |
||
106 | $update[] ="updated ClearWishList"; |
||
107 | } |
||
108 | if (!$page->SavedWishListText) { |
||
109 | $page->SavedWishListText = "saved wish list"; |
||
110 | $update[] ="updated SavedWishListText"; |
||
111 | } |
||
112 | if (!$page->SavedWishListTextError) { |
||
113 | $page->SavedWishListTextError = "could not save wish list"; |
||
114 | $update[] ="updated SavedWishListTextError"; |
||
115 | } |
||
116 | if (!$page->RetrievedWishListText) { |
||
117 | $page->RetrievedWishListText = "retrieved wish list"; |
||
118 | $update[] ="updated RetrievedWishListText"; |
||
119 | } |
||
120 | if (!$page->RetrievedWishListTextError) { |
||
121 | $page->RetrievedWishListTextError = "could not retrieve wish list"; |
||
122 | $update[] ="updated RetrievedWishListTextError"; |
||
123 | } |
||
124 | if (count($update)) { |
||
125 | $page->writeToStage('Stage'); |
||
126 | $page->publish('Stage', 'Live'); |
||
127 | DB::alteration_message($page->ClassName." created/updated: <ul><li>".implode("</li><li>", $update)."</li></ul>", 'created'); |
||
128 | } |
||
129 | } |
||
130 | } |
||
131 | } |
||
179 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.