| Conditions | 11 |
| Paths | 14 |
| Total Lines | 26 |
| Code Lines | 18 |
| 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 |
||
| 79 | public function requireDefaultRecords() |
||
| 80 | { |
||
| 81 | parent::requireDefaultRecords(); |
||
| 82 | $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
||
| 83 | $parents = DataObject::get("BrowseCountriesPage"); |
||
| 84 | if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) { |
||
| 85 | foreach ($parents as $parent) { |
||
| 86 | if ($parent->HiddenDataID) { |
||
| 87 | echo "<li>creating regions for ".$parent->Title."<ul>"; |
||
| 88 | $regions = $this->getDataFromTable("regions", "CountryID = ".$parent->HiddenDataID, "Region"); |
||
| 89 | foreach ($regions as $region) { |
||
| 90 | if (!DataObject::get("BrowseRegionsPage", "{$bt}BrowseAbstractPage{$bt}.{$bt}HiddenDataID{$bt} = ".$region["RegionID"])) { |
||
| 91 | $page = new BrowseRegionsPage(); |
||
| 92 | $page->CreateRegion($region, $parent); |
||
| 93 | $page->destroy(); |
||
| 94 | } |
||
| 95 | } |
||
| 96 | echo "</ul></li>"; |
||
| 97 | } else { |
||
| 98 | if (isset($_GET["geobuild"])) { |
||
| 99 | debug::show("Parent does not exist"); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | } |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 154 |
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.