Conditions | 11 |
Paths | 12 |
Total Lines | 22 |
Code Lines | 15 |
Lines | 14 |
Ratio | 63.64 % |
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 |
||
59 | public function requireDefaultRecords() |
||
60 | { |
||
61 | $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
||
62 | parent::requireDefaultRecords(); |
||
63 | $parents = DataObject::get("BrowseContinentsPage"); |
||
64 | if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) { |
||
65 | View Code Duplication | foreach ($parents as $parent) { |
|
66 | if ($parent->CreateChildren && $parent->HiddenDataID) { |
||
67 | echo "<li>creating countries for ".$parent->Title."<ul>"; |
||
68 | $countries = $this->getDataFromTable("countries", "ContinentID = ".$parent->HiddenDataID, "Country"); |
||
69 | foreach ($countries as $country) { |
||
70 | if (!DataObject::get_one("BrowseCountriesPage", "{$bt}HiddenDataID{$bt} = ".$country["CountryID"])) { |
||
71 | $page = new BrowseCountriesPage(); |
||
72 | $page->CreateCountry($country, $parent); |
||
73 | $page->destroy(); |
||
74 | } |
||
75 | } |
||
76 | echo "</ul></li>"; |
||
77 | } |
||
78 | } |
||
79 | } |
||
80 | } |
||
81 | |||
122 |
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.