| Conditions | 13 | 
| Paths | 52 | 
| Total Lines | 71 | 
| Code Lines | 47 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| 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 | ||
| 45 | public function getListOfConfigs(): array | ||
| 46 |     { | ||
| 47 | $resultArray = []; | ||
| 48 | |||
| 49 |         $doNotShow = $this->Config()->get('do_not_show'); | ||
| 50 | |||
| 51 | $config = Config::inst(); | ||
| 52 | $alsoSet = $config->getAll(); | ||
| 53 | $base = Director::baseFolder(); | ||
| 54 | |||
| 55 | $classes = $this->configurableClasses(); | ||
| 56 |         foreach ($classes as $class) { | ||
| 57 | $reflector = new ReflectionClass($class); | ||
| 58 | $fileName = $reflector->getFileName(); | ||
| 59 | $fileName = str_replace($base, '', $fileName); | ||
| 60 | |||
| 61 | //lists | ||
| 62 | $staticListDelta = $this->getDeltas($config, $class); | ||
| 63 | $staticListDynamic = array_keys($alsoSet[strtolower($class)]); | ||
| 64 | $defaultLists = $this->getDefaultLists($reflector, $doNotShow); | ||
| 65 | $originalValues = $defaultLists['OriginalValues']; | ||
| 66 | |||
| 67 | $lists = [ | ||
| 68 | //do first so that they will always show up | ||
| 69 | 'runtime' => $staticListDelta, | ||
| 70 | 'system' => $defaultLists['Caching'], | ||
| 71 | 'caching' => $defaultLists['System'], | ||
| 72 | 'property' => $defaultLists['Property'], | ||
| 73 | //needs to be last so that only dynamic ones that are | ||
| 74 | //not set as property are included | ||
| 75 | 'dynamic' => $staticListDynamic, | ||
| 76 | ]; | ||
| 77 | |||
| 78 |             foreach ($lists as $type => $list) { | ||
| 79 |                 foreach ($list as $property) { | ||
| 80 |                     $key = str_replace('/', '-', $fileName . '-' . $property); | ||
| 81 |                     if (! isset($resultArray[$key])) { | ||
| 82 | $value = $config->get($class, $property, Config::UNINHERITED); | ||
| 83 | $hasValue = $value ? true : false; | ||
| 84 | $originalValue = isset($originalValues[$property]) ? $originalValues[$property] : ''; | ||
| 85 |                         if (is_object($value)) { | ||
| 86 | $value = 'object'; | ||
| 87 | } | ||
| 88 | $isDefault = true; | ||
| 89 | $default = ''; | ||
| 90 |                         if ($originalValue && $originalValue !== $value) { | ||
| 91 | $isDefault = false; | ||
| 92 |                             if ($value && $originalValue) { | ||
| 93 | $default = $originalValue; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | $hasDefault = $originalValue ? true : false; | ||
| 97 | $resultArray[$key] = array_merge( | ||
| 98 | $this->getClassIntel($class), | ||
| 99 | [ | ||
| 100 | 'FileLocation' => $fileName, | ||
| 101 | 'Property' => $property, | ||
| 102 | 'Type' => $type, | ||
| 103 | 'IsDefault' => $isDefault, | ||
| 104 | 'HasDefault' => $hasDefault, | ||
| 105 | 'HasValue' => $hasValue, | ||
| 106 | 'Default' => $default, | ||
| 107 | 'Value' => $value, | ||
| 108 | ] | ||
| 109 | ); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 115 | return $resultArray; | ||
| 116 | } | ||
| 254 |