| Conditions | 21 | 
| Paths | 17 | 
| Total Lines | 83 | 
| Code Lines | 57 | 
| 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  | 
            ||
| 12 | public function ListOfAllClasses($checkCurrentClass = true)  | 
            ||
| 13 |     { | 
            ||
| 14 |         if (!self::$list_of_all_classes) { | 
            ||
| 15 | $ArrayOfAllClasses = array();  | 
            ||
| 16 |             //$classes = ClassInfo::subclassesFor("SiteTree"); | 
            ||
| 17 | $classes = SiteTree::page_type_classes();  | 
            ||
| 18 | $classesToRemove = array();  | 
            ||
| 19 | |||
| 20 |             foreach ($classes as $className) { | 
            ||
| 21 |                 if (!in_array($className, $this->config()->get("classes_to_exclude"))) { | 
            ||
| 22 |                     if ($this->showAll) { | 
            ||
| 23 | $objects = $className::get()  | 
            ||
| 24 |                             ->filter(array("ClassName" => $className)) | 
            ||
| 25 |                             ->sort("RAND() ASC") | 
            ||
| 26 | ->limit(25);  | 
            ||
| 27 | $count = 0;  | 
            ||
| 28 |                         if ($objects->count()) { | 
            ||
| 29 |                             foreach ($objects as $obj) { | 
            ||
| 30 |                                 if (!$count) { | 
            ||
| 31 |                                     if ($ancestorToHide = $obj->stat('hide_ancestor')) { | 
            ||
| 32 | $classesToRemove[] = $ancestorToHide;  | 
            ||
| 33 | }  | 
            ||
| 34 | }  | 
            ||
| 35 | $object = $this->createPageObject($obj, $count++);  | 
            ||
| 36 | $ArrayOfAllClasses[$object->indexNumber] = clone $object;  | 
            ||
| 37 | }  | 
            ||
| 38 | }  | 
            ||
| 39 |                     } else { | 
            ||
| 40 | $obj = null;  | 
            ||
| 41 | $obj = $className::get()  | 
            ||
| 42 |                             ->filter(array("ClassName" => $className)) | 
            ||
| 43 |                             ->sort("RAND() ASC") | 
            ||
| 44 | ->limit(1)  | 
            ||
| 45 | ->first();  | 
            ||
| 46 |                         if ($obj) { | 
            ||
| 47 |                             $count = SiteTree::get()->filter(array("ClassName" => $obj->ClassName))->count(); | 
            ||
| 48 |                         } else { | 
            ||
| 49 | $obj = $className::create();  | 
            ||
| 50 | $count = 0;  | 
            ||
| 51 | }  | 
            ||
| 52 |                         if ($ancestorToHide = $obj->stat('hide_ancestor')) { | 
            ||
| 53 | $classesToRemove[] = $ancestorToHide;  | 
            ||
| 54 | }  | 
            ||
| 55 | $object = $this->createPageObject($obj, $count);  | 
            ||
| 56 | $object->TemplateOverviewDescription = $this->TemplateDetails($className);  | 
            ||
| 57 | $ArrayOfAllClasses[$object->indexNumber] = clone $object;  | 
            ||
| 58 | }  | 
            ||
| 59 | }  | 
            ||
| 60 | }  | 
            ||
| 61 | |||
| 62 | //remove the hidden ancestors...  | 
            ||
| 63 |             if ($classesToRemove && count($classesToRemove)) { | 
            ||
| 64 | $classesToRemove = array_unique($classesToRemove);  | 
            ||
| 65 | // unset from $classes  | 
            ||
| 66 |                 foreach ($ArrayOfAllClasses as $tempKey => $tempClass) { | 
            ||
| 67 |                     if (in_array($tempClass->ClassName, $classesToRemove)) { | 
            ||
| 68 | unset($ArrayOfAllClasses[$tempKey]);  | 
            ||
| 69 | }  | 
            ||
| 70 | }  | 
            ||
| 71 | }  | 
            ||
| 72 | ksort($ArrayOfAllClasses);  | 
            ||
| 73 | self::$list_of_all_classes = new ArrayList();  | 
            ||
| 74 | $currentClassname = '';  | 
            ||
| 75 |             if ($checkCurrentClass) { | 
            ||
| 76 |                 if ($c = Controller::curr()) { | 
            ||
| 77 |                     if ($d = $c->dataRecord) { | 
            ||
| 78 | $currentClassname = $d->ClassName;  | 
            ||
| 79 | }  | 
            ||
| 80 | }  | 
            ||
| 81 | }  | 
            ||
| 82 |             if (count($ArrayOfAllClasses)) { | 
            ||
| 83 |                 foreach ($ArrayOfAllClasses as $item) { | 
            ||
| 84 |                     if ($item->ClassName == $currentClassname) { | 
            ||
| 85 | $item->LinkingMode = "current";  | 
            ||
| 86 |                     } else { | 
            ||
| 87 | $item->LinkingMode = "link";  | 
            ||
| 88 | }  | 
            ||
| 89 | self::$list_of_all_classes->push($item);  | 
            ||
| 90 | }  | 
            ||
| 91 | }  | 
            ||
| 92 | }  | 
            ||
| 93 | return self::$list_of_all_classes;  | 
            ||
| 94 | }  | 
            ||
| 95 | |||
| 172 | 
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.