Conditions | 11 |
Paths | 12 |
Total Lines | 23 |
Code Lines | 16 |
Lines | 14 |
Ratio | 60.87 % |
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 |
||
75 | public function requireDefaultRecords() |
||
76 | { |
||
77 | parent::requireDefaultRecords(); |
||
78 | $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
||
79 | $parents = DataObject::get("BrowseRegionsPage"); |
||
80 | if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) { |
||
81 | View Code Duplication | foreach ($parents as $parent) { |
|
82 | if ($parent->CreateChildren && $parent->HiddenDataID) { |
||
83 | echo "<li>creating cities for ".$parent->Title."<ul>"; |
||
84 | $cities = $this->getDataFromTable("cities", "RegionID = ".$parent->HiddenDataID, "City"); |
||
85 | foreach ($cities as $city) { |
||
86 | if (!DataObject::get_one("BrowseCitiesPage", "{$bt}BrowseAbstractPage{$bt}.{$bt}HiddenDataID{$bt} = ".$city["CityID"])) { |
||
87 | $page = new BrowseCitiesPage(); |
||
88 | $page->CreateCity($city, $parent); |
||
89 | $page->destroy(); |
||
90 | } |
||
91 | } |
||
92 | echo "</ul></li>"; |
||
93 | } |
||
94 | } |
||
95 | $parents->destroy(); |
||
96 | } |
||
97 | } |
||
98 | |||
146 |
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.