| Conditions | 1 |
| Paths | 1 |
| Total Lines | 70 |
| Code Lines | 42 |
| 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 |
||
| 84 | public function getFunctions(): array |
||
| 85 | { |
||
| 86 | return [ |
||
| 87 | new TwigFunction(self::FUNCTION_GET_PUBLIC_FOLDER_PATH, function ($relativePath) { |
||
| 88 | $publicFolderPath = $this->getPublicFolderPath(); |
||
| 89 | |||
| 90 | return $publicFolderPath . $relativePath; |
||
| 91 | }, [ |
||
| 92 | $this, |
||
| 93 | self::FUNCTION_GET_PUBLIC_FOLDER_PATH, |
||
| 94 | ]), |
||
| 95 | |||
| 96 | new TwigFunction(self::FUNCTION_GET_QA_ATTRIBUTE, function (array $qaValues = []) { |
||
| 97 | return $this->getQaAttribute($qaValues); |
||
| 98 | }, [ |
||
| 99 | $this, |
||
| 100 | self::FUNCTION_GET_QA_ATTRIBUTE, |
||
| 101 | 'is_safe' => ['html'], |
||
| 102 | 'is_variadic' => true, |
||
| 103 | ]), |
||
| 104 | |||
| 105 | new TwigFunction(self::FUNCTION_GET_QA_ATTRIBUTE_SUB, function ($qaName, array $qaValues = []) { |
||
| 106 | return $this->getQaAttribute($qaValues, $qaName); |
||
| 107 | }, [ |
||
| 108 | $this, |
||
| 109 | self::FUNCTION_GET_QA_ATTRIBUTE_SUB, |
||
| 110 | 'is_safe' => ['html'], |
||
| 111 | 'is_variadic' => true, |
||
| 112 | ]), |
||
| 113 | |||
| 114 | new TwigFunction(self::FUNCTION_GET_UI_MODEL_COMPONENT_TEMPLATE, function ($modelName) { |
||
| 115 | return $this->getModelTemplate($modelName); |
||
| 116 | }, [ |
||
| 117 | $this, |
||
| 118 | self::FUNCTION_GET_UI_MODEL_COMPONENT_TEMPLATE, |
||
| 119 | ]), |
||
| 120 | |||
| 121 | new TwigFunction(self::FUNCTION_GET_UI_ATOM_COMPONENT_TEMPLATE, function ($componentName, $componentModule = self::DEFAULT_MODULE) { |
||
| 122 | return $this->getComponentTemplate($componentModule, 'atoms', $componentName); |
||
| 123 | }, [ |
||
| 124 | $this, |
||
| 125 | self::FUNCTION_GET_UI_ATOM_COMPONENT_TEMPLATE, |
||
| 126 | ]), |
||
| 127 | |||
| 128 | new TwigFunction(self::FUNCTION_GET_UI_MOLECULE_COMPONENT_TEMPLATE, function ($componentName, $componentModule = self::DEFAULT_MODULE) { |
||
| 129 | return $this->getComponentTemplate($componentModule, 'molecules', $componentName); |
||
| 130 | }, [ |
||
| 131 | $this, |
||
| 132 | self::FUNCTION_GET_UI_MOLECULE_COMPONENT_TEMPLATE, |
||
| 133 | ]), |
||
| 134 | |||
| 135 | new TwigFunction(self::FUNCTION_GET_UI_ORGANISM_COMPONENT_TEMPLATE, function ($componentName, $componentModule = self::DEFAULT_MODULE) { |
||
| 136 | return $this->getComponentTemplate($componentModule, 'organisms', $componentName); |
||
| 137 | }, [ |
||
| 138 | $this, |
||
| 139 | self::FUNCTION_GET_UI_ORGANISM_COMPONENT_TEMPLATE, |
||
| 140 | ]), |
||
| 141 | |||
| 142 | new TwigFunction(self::FUNCTION_GET_UI_TEMPLATE_COMPONENT_TEMPLATE, function ($templateName, $templateModule = self::DEFAULT_MODULE) { |
||
| 143 | return $this->getTemplateTemplate($templateModule, $templateName); |
||
| 144 | }, [ |
||
| 145 | $this, |
||
| 146 | self::FUNCTION_GET_UI_TEMPLATE_COMPONENT_TEMPLATE, |
||
| 147 | ]), |
||
| 148 | |||
| 149 | new TwigFunction(self::FUNCTION_GET_UI_VIEW_COMPONENT_TEMPLATE, function ($viewName, $viewModule = self::DEFAULT_MODULE) { |
||
| 150 | return $this->getViewTemplate($viewModule, $viewName); |
||
| 151 | }, [ |
||
| 152 | $this, |
||
| 153 | self::FUNCTION_GET_UI_VIEW_COMPONENT_TEMPLATE, |
||
| 154 | ]), |
||
| 280 |