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