| Conditions | 1 |
| Paths | 1 |
| Total Lines | 63 |
| Code Lines | 53 |
| 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 |
||
| 63 | private function getUsers(): array |
||
| 64 | { |
||
| 65 | return [ |
||
| 66 | [ |
||
| 67 | 'id' => 'john.1', |
||
| 68 | 'public_id' => UserAccountId::create('john.1'), |
||
| 69 | 'username' => 'john.1', |
||
| 70 | 'password' => 'secret', |
||
| 71 | 'salt' => null, |
||
| 72 | 'roles' => ['ROLE_USER'], |
||
| 73 | 'last_login_at' => time() - 100, |
||
| 74 | 'parameters' => [ |
||
| 75 | 'password' => 'doe', |
||
| 76 | 'user' => 'john', |
||
| 77 | 'address', [ |
||
| 78 | 'street_address' => '5 rue Sainte Anne', |
||
| 79 | 'region' => 'Île de France', |
||
| 80 | 'postal_code' => '75001', |
||
| 81 | 'locality' => 'Paris', |
||
| 82 | 'country' => 'France', |
||
| 83 | ], |
||
| 84 | 'name' => 'John Doe', |
||
| 85 | 'given_name' => 'John', |
||
| 86 | 'family_name' => 'Doe', |
||
| 87 | 'middle_name' => 'Jack', |
||
| 88 | 'nickname' => 'Little John', |
||
| 89 | 'profile' => 'https://profile.doe.fr/john/', |
||
| 90 | 'preferred_username' => 'j-d', |
||
| 91 | 'gender' => 'M', |
||
| 92 | 'phone_number' => '+0123456789', |
||
| 93 | 'phone_number_verified' => true, |
||
| 94 | 'updated_at' => 1485431232, |
||
| 95 | 'zoneinfo' => 'Europe/Paris', |
||
| 96 | 'locale' => 'en', |
||
| 97 | 'picture' => 'https://www.google.com', |
||
| 98 | 'amr' => ['password' => 'otp'], |
||
| 99 | 'birthdate' => '1950-01-01', |
||
| 100 | 'email' => '[email protected]', |
||
| 101 | 'email_verified' => false, |
||
| 102 | 'last_login_at' => time() - 100, |
||
| 103 | 'website' => 'https://john.doe.com', |
||
| 104 | 'website#fr_fr' => 'https://john.doe.fr', |
||
| 105 | 'website#fr' => 'https://john.doe.fr', |
||
| 106 | 'picture#de' => 'https://john.doe.de/picture', |
||
| 107 | ], |
||
| 108 | 'oauth2Passwords' => ['password.1'], |
||
| 109 | ], |
||
| 110 | [ |
||
| 111 | 'id' => 'john.2', |
||
| 112 | 'public_id' => UserAccountId::create('john.2'), |
||
| 113 | 'username' => 'john.2', |
||
| 114 | 'password' => 'secret', |
||
| 115 | 'salt' => null, |
||
| 116 | 'roles' => ['ROLE_USER'], |
||
| 117 | 'last_login_at' => time() - 100, |
||
| 118 | 'parameters' => [ |
||
| 119 | 'password' => 'doe', |
||
| 120 | 'user' => 'john', |
||
| 121 | ], |
||
| 122 | 'oauth2Passwords' => ['doe'], |
||
| 123 | ], |
||
| 124 | ]; |
||
| 125 | } |
||
| 126 | } |
||
| 127 |