| Conditions | 18 | 
| Paths | 256 | 
| Total Lines | 88 | 
| Code Lines | 63 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | ||
| 46 | public function getListOfConfigs(): array | ||
| 47 |     { | ||
| 48 | $resultArray = []; | ||
| 49 | |||
| 50 |         $doNotShow = $this->Config()->get('do_not_show'); | ||
| 51 | |||
| 52 | $config = Config::inst(); | ||
| 53 | $alsoSet = $config->getAll(); | ||
| 54 | $base = Director::baseFolder(); | ||
| 55 | |||
| 56 | $classes = $this->configurableClasses(); | ||
| 57 |         foreach ($classes as $class) { | ||
| 58 | $reflector = new ReflectionClass($class); | ||
| 59 | $fileName = $reflector->getFileName(); | ||
| 60 | $fileName = str_replace($base, '', $fileName); | ||
| 61 | $statics = $reflector->getStaticProperties(); | ||
| 62 | |||
| 63 | //lists | ||
| 64 | $staticListSystem = []; | ||
| 65 | $staticListProperty = []; | ||
| 66 | $staticListCaching = []; | ||
| 67 | $staticListDelta = $this->getDeltas($config, $class); | ||
| 68 | $staticListDynamic = array_keys($alsoSet[strtolower($class)]); | ||
| 69 | unset($originalValues); | ||
| 70 | $originalValues = []; | ||
| 71 |             foreach ($statics as $property => $details) { | ||
| 72 | $propertyObject = $reflector->getProperty($property); | ||
| 73 |                 if($propertyObject->isPrivate()) { | ||
| 74 | $propertyObject->setAccessible(true); | ||
| 75 | $originalValues[$property] = $propertyObject->getValue($reflector); | ||
| 76 | |||
| 77 |                     if (in_array($property, $doNotShow, true)) { | ||
| 78 | $staticListSystem[$property] = $property; | ||
| 79 | } elseif (substr($property, 0, 1) === '_' || | ||
| 80 | strpos($property, 'cache') !== false | ||
| 81 |                     ) { | ||
| 82 | $staticListCaching[$property] = $property; | ||
| 83 |                     } else { | ||
| 84 | $staticListProperty[$property] = $property; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
| 88 | $lists = [ | ||
| 89 | 'runtime' => $staticListDelta, | ||
| 90 | 'caching' => $staticListCaching, | ||
| 91 | 'system' => $staticListSystem, | ||
| 92 | 'property' => $staticListProperty, | ||
| 93 | 'dynamic' => $staticListDynamic, | ||
| 94 | ]; | ||
| 95 | |||
| 96 |             foreach ($lists as $type => $list) { | ||
| 97 |                 foreach ($list as $property) { | ||
| 98 |                     $key = str_replace('/', '-', $fileName . '-' . $property); | ||
| 99 |                     if (! isset($resultArray[$key])) { | ||
| 100 | $value = $config->get($class, $property, Config::UNINHERITED); | ||
| 101 | $hasValue = $value ? true : false; | ||
| 102 | $originalValue = isset($originalValues[$property]) ? $originalValues[$property] : ''; | ||
| 103 |                         if (is_object($value)) { | ||
| 104 | $value = 'object'; | ||
| 105 | } | ||
| 106 | $isDefault = true; | ||
| 107 | $default = ''; | ||
| 108 |                         if ($originalValue && $originalValue !== $value) { | ||
| 109 | $isDefault = false; | ||
| 110 |                             if ($value && $originalValue) { | ||
| 111 | $default = $originalValue; | ||
| 112 | } | ||
| 113 | } | ||
| 114 | $hasDefault = $originalValue ? true : false; | ||
| 115 | $resultArray[$key] = array_merge( | ||
| 116 | $this->getClassIntel($class), | ||
| 117 | [ | ||
| 118 | 'FileLocation' => $fileName, | ||
| 119 | 'Property' => $property, | ||
| 120 | 'Type' => $type, | ||
| 121 | 'IsDefault' => $isDefault, | ||
| 122 | 'HasDefault' => $hasDefault, | ||
| 123 | 'HasValue' => $hasValue, | ||
| 124 | 'Default' => $default, | ||
| 125 | 'Value' => $value, | ||
| 126 | ] | ||
| 127 | ); | ||
| 128 | } | ||
| 129 | } | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | return $resultArray; | ||
| 134 | } | ||
| 233 |