Complex classes like UserController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use UserController, and based on these observations, apply Extract Interface, too.
| 1 | <?php namespace Mascame\Artificer\Http\Controllers; |
||
| 13 | class UserController extends BaseController |
||
| 14 | { |
||
| 15 | |||
| 16 | public $tries_key = 'artificer.user.login.tries'; |
||
| 17 | public $ban_key = 'artificer.user.login.banned'; |
||
| 18 | public $authProvider; |
||
| 19 | |||
| 20 | public function __construct() { |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Unban user |
||
| 28 | */ |
||
| 29 | private function unban() |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return bool |
||
| 36 | */ |
||
| 37 | private function isBanned() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Ban user |
||
| 54 | */ |
||
| 55 | private function ban() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * |
||
| 62 | */ |
||
| 63 | private function addAttempt() |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View |
||
| 83 | */ |
||
| 84 | public function showLogin() |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @return $this|\Illuminate\Http\RedirectResponse |
||
| 93 | */ |
||
| 94 | public function login() |
||
| 120 | |||
| 121 | protected function successLoginRedirect() { |
||
| 124 | |||
| 125 | protected function failedLoginRedirect() { |
||
| 129 | |||
| 130 | protected static function attempt($attemptClosure, $credentials) { |
||
| 133 | |||
| 134 | protected static function getClosureAttempt() { |
||
| 137 | |||
| 138 | protected static function getClosureCheckAuth() { |
||
| 141 | |||
| 142 | protected static function checkAuth($checkClosure) { |
||
| 145 | |||
| 146 | public static function check() { |
||
| 149 | |||
| 150 | protected function onFailValidation($validator) |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @return \Illuminate\Database\Eloquent\Model|null|static |
||
| 161 | */ |
||
| 162 | protected function getUser() |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @param $user |
||
| 170 | * @return bool |
||
| 171 | */ |
||
| 172 | protected function attemptLogin($user) |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @param \Illuminate\Database\Eloquent\Model|null $user |
||
| 193 | * @return bool |
||
| 194 | */ |
||
| 195 | protected function isValidUser($user) |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @return \Illuminate\Http\RedirectResponse |
||
| 208 | */ |
||
| 209 | public function logout() |
||
| 215 | |||
| 216 | |||
| 217 | public function authFilter() { |
||
| 240 | } |
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.