Conditions | 18 |
Paths | 18 |
Total Lines | 47 |
Code Lines | 31 |
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 |
||
92 | public function __call($method, $args = []) |
||
93 | { |
||
94 | $model = models($this->model->getClass()); |
||
95 | |||
96 | if (method_exists($model, $method)) { |
||
97 | $model->row = $this; |
||
98 | |||
99 | if (false !== ($result = call_user_func_array([&$model, $method], $args))) { |
||
100 | $this->offsetSet($method, $result); |
||
101 | |||
102 | return $result; |
||
103 | } |
||
104 | } elseif (strpos($method, 'Url')) { |
||
105 | $key = str_replace('Url', '', $method); |
||
106 | |||
107 | if ($key === $model->uploadedImageKey) { |
||
108 | if (isset($model->uploadedImageFilePath)) { |
||
109 | if (is_file($filePath = $model->uploadedImageFilePath . $this->offsetGet($key))) { |
||
110 | return images_url($filePath); |
||
111 | } elseif (is_file($filePath = PATH_STORAGE . 'images/default/not-found.jpg')) { |
||
112 | return images_url($filePath); |
||
113 | } elseif (is_file($filePath = PATH_STORAGE . 'images/default/not-found.png')) { |
||
114 | return images_url($filePath); |
||
115 | } |
||
116 | } |
||
117 | } elseif (in_array($key, $model->uploadedImageKeys)) { |
||
118 | if (isset($model->uploadedImageFilePath)) { |
||
119 | if (is_file($filePath = $model->uploadedImageFilePath . $this->offsetGet($key))) { |
||
120 | return images_url($filePath); |
||
121 | } elseif (is_file($filePath = PATH_STORAGE . 'images/default/not-found.jpg')) { |
||
122 | return images_url($filePath); |
||
123 | } elseif (is_file($filePath = PATH_STORAGE . 'images/default/not-found.png')) { |
||
124 | return images_url($filePath); |
||
125 | } |
||
126 | } |
||
127 | } elseif ($key === $model->uploadedFileKey) { |
||
128 | if (isset($model->uploadedFileFilepath)) { |
||
129 | return storage_url($model->uploadedFileFilepath . $this->offsetGet($key)); |
||
130 | } |
||
131 | } elseif (in_array($key, $model->uploadedFileKeys)) { |
||
132 | if (isset($model->uploadedFileFilepath)) { |
||
133 | return storage_url($model->uploadedFileFilepath . $this->offsetGet($key)); |
||
134 | } |
||
135 | } |
||
136 | } |
||
137 | |||
138 | return null; |
||
139 | } |
||
171 | } |
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.