| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 157 | private static function createContactResponse(?Contact $contact): array |
||
| 158 | { |
||
| 159 | $faker = Factory::create('tr_TR'); |
||
| 160 | |||
| 161 | return [ |
||
| 162 | 'data' => [ |
||
| 163 | 'id' => (string) $faker->numberBetween(10000, 99999), |
||
| 164 | 'type' => 'contacts', |
||
| 165 | 'attributes' => [ |
||
| 166 | 'created_at' => $contact->created_at ?? $faker->iso8601, |
||
| 167 | 'updated_at' => $contact->updated_at ?? $faker->iso8601, |
||
| 168 | 'contact_type' => $contact->contact_type ?? 'company', |
||
|
|
|||
| 169 | 'name' => $contact->name ?? $faker->name, |
||
| 170 | 'email' => $contact->email ?? null, |
||
| 171 | 'short_name' => $contact->short_name ?? null, |
||
| 172 | 'balance' => $contact->balance ?? '0.0', |
||
| 173 | 'trl_balance' => $contact->trl_balance ?? '0.0', |
||
| 174 | 'usd_balance' => $contact->usd_balance ?? '0.0', |
||
| 175 | 'eur_balance' => $contact->eur_balance ?? '0.0', |
||
| 176 | 'gbp_balance' => $contact->gbp_balance ?? '0.0', |
||
| 177 | 'tax_number' => $contact->tax_number ?? null, |
||
| 178 | 'tax_office' => $contact->tax_office ?? null, |
||
| 179 | 'archived' => $contact->archived ?? false, |
||
| 180 | 'account_type' => $contact->account_type ?? $faker->randomElement(['customer', 'supplier']), |
||
| 181 | 'city' => $contact->city ?? null, |
||
| 182 | 'district' => $contact->district ?? null, |
||
| 183 | 'address' => $contact->address ?? null, |
||
| 184 | 'phone' => $contact->phone ?? null, |
||
| 185 | 'fax' => $contact->fax ?? null, |
||
| 186 | 'is_abroad' => $contact->is_abroad ?? false, |
||
| 187 | 'term_days' => $contact->term_days ?? null, |
||
| 188 | 'invoicing_preferences' => $contact->invoicing_preferences ?? [], |
||
| 189 | 'sharings_count' => $contact->sharings_count ?? 0, |
||
| 190 | 'ibans' => $contact->ibans ?? [], |
||
| 191 | 'exchange_rate_type' => $contact->exchange_rate_type ?? 'buying', |
||
| 192 | 'iban' => $contact->iban ?? null, |
||
| 193 | 'sharing_preview_url' => 'https://uygulama.parasut.com/'.config('parasut.company_id').'/portal/preview/'.$faker->numberBetween(1000, 9999), |
||
| 194 | 'sharing_preview_path' => '/'.config('parasut.company_id').'/portal/preview/'.$faker->numberBetween(1000, 9999), |
||
| 195 | 'payment_reminder_preview_url' => 'https://uygulama.parasut.com/'.config('parasut.company_id').'/portal/preview/'.$faker->numberBetween(1000, 9999).'/odeme-hatirlat', |
||
| 196 | ], |
||
| 197 | 'relationships' => [ |
||
| 198 | 'category' => ['meta' => []], |
||
| 199 | 'price_list' => ['meta' => []], |
||
| 200 | 'contact_portal' => ['meta' => []], |
||
| 201 | 'contact_people' => ['meta' => []], |
||
| 202 | 'activities' => ['meta' => []], |
||
| 203 | 'e_invoice_inboxes' => ['meta' => []], |
||
| 204 | 'sharings' => ['meta' => []], |
||
| 205 | ], |
||
| 206 | 'meta' => [ |
||
| 207 | 'created_at' => $contact->created_at ?? $faker->iso8601, |
||
| 208 | 'updated_at' => $contact->updated_at ?? $faker->iso8601, |
||
| 209 | ], |
||
| 244 |