| Conditions | 9 |
| Paths | 13 |
| Total Lines | 56 |
| Code Lines | 33 |
| 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 |
||
| 69 | public function get($offset) |
||
| 70 | { |
||
| 71 | if (null !== ($widget = parent::get($offset))) { |
||
| 72 | |||
| 73 | $widgetViewFilePath = $widget->getRealPath() . 'Views' . DIRECTORY_SEPARATOR . $offset . '.phtml'; |
||
| 74 | |||
| 75 | if (presenter()->theme->use === true) { |
||
| 76 | $widgetViewReplacementPath = str_replace( |
||
| 77 | $widget->getRealPath() . 'Views' . DIRECTORY_SEPARATOR, |
||
| 78 | presenter()->theme->active->getPathName() . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, [ |
||
| 79 | 'views', |
||
| 80 | 'widgets', |
||
| 81 | ]) . DIRECTORY_SEPARATOR, |
||
| 82 | $widgetViewFilePath |
||
| 83 | ); |
||
| 84 | |||
| 85 | $viewsFileExtensions = [ |
||
| 86 | '.php', |
||
| 87 | '.phtml', |
||
| 88 | ]; |
||
| 89 | |||
| 90 | // Add Theme File Extensions |
||
| 91 | if (presenter()->theme->active->getPresets()->offsetExists('extension')) { |
||
| 92 | array_unshift($viewsFileExtensions, |
||
| 93 | presenter()->theme->active->getPresets()->offsetGet('extension')); |
||
| 94 | } elseif (presenter()->theme->active->getPresets()->offsetExists('extensions')) { |
||
| 95 | $viewsFileExtensions = array_merge( |
||
| 96 | presenter()->theme->active->getPresets()->offsetGet('extensions'), |
||
| 97 | $viewsFileExtensions |
||
| 98 | ); |
||
| 99 | } |
||
| 100 | |||
| 101 | foreach ($viewsFileExtensions as $viewsFileExtension) { |
||
| 102 | if (is_file($widgetViewReplacementPath . $viewsFileExtension)) { |
||
| 103 | $widgetViewFilePath = $widgetViewReplacementPath . $viewsFileExtension; |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | } |
||
| 108 | |||
| 109 | loader()->addNamespace($widget->getNamespace(), $widget->getRealPath()); |
||
| 110 | $widgetPresenterClassName = $widgetPresenterClassName = $widget->getNamespace() . 'Presenters\\' . studlycase($offset); |
||
| 111 | |||
| 112 | $widgetPresenter = new $widgetPresenterClassName(); |
||
| 113 | |||
| 114 | if (is_file($widgetViewFilePath)) { |
||
| 115 | parser()->loadVars($widgetPresenter->getArrayCopy()); |
||
| 116 | parser()->loadFile($widgetViewFilePath); |
||
| 117 | |||
| 118 | return parser()->parse(); |
||
| 119 | } elseif (method_exists($widgetPresenter, 'render')) { |
||
| 120 | return $widgetPresenter->render(); |
||
| 121 | } |
||
| 122 | } |
||
| 123 | |||
| 124 | return null; |
||
| 125 | } |
||
| 126 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.