| Conditions | 15 |
| Paths | 36 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 15 |
| Changes | 1 | ||
| 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 |
||
| 21 | 2 | public function __construct(...$params) |
|
| 22 | { |
||
| 23 | 2 | foreach ($params as $param) { |
|
| 24 | 2 | if (is_object($param)) { |
|
| 25 | 2 | if ((!$this->auth) && $param instanceof Interfaces\IAuth) { |
|
| 26 | 2 | $this->auth = $param; |
|
| 27 | } |
||
| 28 | 2 | if ((!$this->accounts) && $param instanceof Interfaces\IWorkAccounts) { |
|
| 29 | 2 | $this->accounts = $param; |
|
| 30 | } |
||
| 31 | 2 | if ((!$this->classes) && $param instanceof Interfaces\IWorkClasses) { |
|
| 32 | 1 | $this->classes = $param; |
|
| 33 | } |
||
| 34 | 2 | if ((!$this->groups) && $param instanceof Interfaces\IWorkGroups) { |
|
| 35 | 2 | $this->groups = $param; |
|
| 36 | } |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | 2 | if (!($this->auth && $this->accounts && $this->classes && $this->groups)) { |
|
| 41 | 1 | throw new AuthSourcesException('You must set all necessary classes in the params first!'); |
|
| 42 | } |
||
| 45 |