| Total Complexity | 59 |
| Total Lines | 646 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like ProductController 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.
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 ProductController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 26 | class ProductController extends BaseProductController |
||
| 27 | { |
||
| 28 | public $product; |
||
| 29 | public $price; |
||
| 30 | public $type; |
||
| 31 | public $subscription; |
||
| 32 | public $currency; |
||
| 33 | public $group; |
||
| 34 | public $plan; |
||
| 35 | public $tax; |
||
| 36 | public $tax_relation; |
||
| 37 | public $tax_class; |
||
| 38 | public $product_upload; |
||
| 39 | |||
| 40 | public function __construct() |
||
| 41 | { |
||
| 42 | $this->middleware('auth'); |
||
| 43 | $this->middleware('admin', ['except' => ['adminDownload', 'userDownload']]); |
||
| 44 | |||
| 45 | $product = new Product(); |
||
| 46 | $this->product = $product; |
||
| 47 | |||
| 48 | $price = new Price(); |
||
| 49 | $this->price = $price; |
||
| 50 | |||
| 51 | $type = new Type(); |
||
| 52 | $this->type = $type; |
||
| 53 | |||
| 54 | $subscription = new Subscription(); |
||
| 55 | $this->subscription = $subscription; |
||
| 56 | |||
| 57 | $currency = new Currency(); |
||
| 58 | $this->currency = $currency; |
||
| 59 | |||
| 60 | $group = new ProductGroup(); |
||
| 61 | $this->group = $group; |
||
| 62 | |||
| 63 | $plan = new Plan(); |
||
| 64 | $this->plan = $plan; |
||
| 65 | |||
| 66 | $tax = new Tax(); |
||
| 67 | $this->tax = $tax; |
||
| 68 | |||
| 69 | $period = new Period(); |
||
| 70 | $this->period = $period; |
||
| 71 | |||
| 72 | $tax_relation = new TaxProductRelation(); |
||
| 73 | $this->tax_relation = $tax_relation; |
||
| 74 | |||
| 75 | $tax_class = new TaxClass(); |
||
| 76 | $this->tax_class = $tax_class; |
||
| 77 | |||
| 78 | $product_upload = new ProductUpload(); |
||
| 79 | $this->product_upload = $product_upload; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Display a listing of the resource. |
||
| 84 | * |
||
| 85 | * @return \Response |
||
| 86 | */ |
||
| 87 | public function index() |
||
| 88 | { |
||
| 89 | try { |
||
| 90 | return view('themes.default1.product.product.index'); |
||
| 91 | } catch (\Exception $e) { |
||
| 92 | Bugsnag::notifyException($e); |
||
| 93 | |||
| 94 | return redirect('/')->with('fails', $e->getMessage()); |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Display a listing of the resource. |
||
| 100 | * |
||
| 101 | * @return \Response |
||
| 102 | */ |
||
| 103 | public function getProducts() |
||
| 161 | } |
||
| 162 | } |
||
| 163 | |||
| 164 | public function getUpload($id) |
||
| 165 | { |
||
| 166 | $new_upload = ProductUpload::where('product_id', '=', $id) |
||
| 167 | ->select('id', 'product_id', 'title', 'description', 'version', 'file') |
||
| 168 | ->get(); |
||
| 169 | |||
| 170 | return \DataTables::of($new_upload) |
||
| 171 | ->addColumn('checkbox', function ($model) { |
||
| 172 | return "<input type='checkbox' class='upload_checkbox' value=".$model->id.' name=select[] id=checks>'; |
||
| 173 | }) |
||
| 174 | |||
| 175 | ->addColumn('product_id', function ($model) { |
||
| 176 | return ucfirst($this->product->where('id', $model->product_id)->first()->name); |
||
| 177 | }) |
||
| 178 | |||
| 179 | ->addColumn('title', function ($model) { |
||
| 180 | return ucfirst($model->title); |
||
| 181 | }) |
||
| 182 | ->addColumn('description', function ($model) { |
||
| 183 | return ucfirst($model->description); |
||
| 184 | }) |
||
| 185 | ->addColumn('version', function ($model) { |
||
| 186 | return $model->version; |
||
| 187 | }) |
||
| 188 | |||
| 189 | ->addColumn('file', function ($model) { |
||
| 190 | return $model->file; |
||
| 191 | }) |
||
| 192 | ->addColumn('action', function ($model) { |
||
| 193 | return '<a href='.('#edit-upload-option/'.$model->id).' |
||
| 194 | class=" btn btn-sm btn-primary " data-title="'.$model->title.'" |
||
| 195 | data-description="'.$model->description.'" data-version="' |
||
| 196 | .$model->version.'" data-id="'.$model->id.'" onclick="openEditPopup(this)" >Edit</a>'; |
||
| 197 | }) |
||
| 198 | ->rawcolumns(['checkbox', 'product_id', 'title', 'description', 'version', 'file', 'action']) |
||
| 199 | ->make(true); |
||
| 200 | } |
||
| 201 | |||
| 202 | // Save file Info in Modal popup |
||
| 203 | public function save(Request $request) |
||
| 204 | { |
||
| 205 | try { |
||
| 206 | $product_id = Product::where('name', '=', $request->input('product'))->select('id')->first(); |
||
| 207 | |||
| 208 | $this->product_upload->product_id = $product_id->id; |
||
| 209 | $this->product_upload->title = $request->input('title'); |
||
| 210 | $this->product_upload->description = $request->input('description'); |
||
| 211 | $this->product_upload->version = $request->input('version'); |
||
| 212 | |||
| 213 | if ($request->file) { |
||
| 214 | $file = $request->file('file')->getClientOriginalName(); |
||
| 215 | |||
| 216 | $destination = storage_path().'/products'; |
||
| 217 | $request->file('file')->move($destination, $file); |
||
| 218 | $this->product_upload->file = $file; |
||
| 219 | } |
||
| 220 | $this->product_upload->save(); |
||
| 221 | |||
| 222 | return redirect()->back()->with('success', \Lang::get('message.saved-successfully')); |
||
| 223 | } catch (\Exception $e) { |
||
| 224 | Bugsnag::notifyException($e); |
||
| 225 | |||
| 226 | return redirect()->with('fails', $e->getMessage()); |
||
| 227 | } |
||
| 228 | } |
||
| 229 | |||
| 230 | //Update the File Info |
||
| 231 | public function uploadUpdate($id, Request $request) |
||
| 232 | { |
||
| 233 | $file_upload = ProductUpload::find($id); |
||
| 234 | |||
| 235 | $file_upload->title = $request->input('title'); |
||
| 236 | $file_upload->description = $request->input('description'); |
||
| 237 | $file_upload->version = $request->input('version'); |
||
| 238 | if ($request->file) { |
||
| 239 | $file = $request->file('file')->getClientOriginalName(); |
||
| 240 | |||
| 241 | $destination = storage_path().'/products'; |
||
| 242 | $request->file('file')->move($destination, $file); |
||
| 243 | $file_upload->file = $file; |
||
| 244 | } |
||
| 245 | $file_upload->save(); |
||
| 246 | |||
| 247 | return redirect()->back()->with('success', \Lang::get('message.saved-successfully')); |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Show the form for creating a new resource. |
||
| 252 | * |
||
| 253 | * @return \Response |
||
| 254 | */ |
||
| 255 | public function create() |
||
| 279 | } |
||
| 280 | } |
||
| 281 | |||
| 282 | /** |
||
| 283 | * Store a newly created resource in storage. |
||
| 284 | * |
||
| 285 | * @return \Response |
||
| 286 | */ |
||
| 287 | public function store(Request $request) |
||
| 343 | } |
||
| 344 | } |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Show the form for editing the specified resource. |
||
| 348 | * |
||
| 349 | * @param int $id |
||
| 350 | * |
||
| 351 | * @return \Response |
||
| 352 | */ |
||
| 353 | public function edit($id) |
||
| 354 | { |
||
| 355 | try { |
||
| 356 | $type = $this->type->pluck('name', 'id')->toArray(); |
||
| 357 | |||
| 358 | $subscription = $this->plan->pluck('name', 'id')->toArray(); |
||
| 359 | $currency = $this->currency->pluck('name', 'code')->toArray(); |
||
| 360 | $group = $this->group->pluck('name', 'id')->toArray(); |
||
| 361 | $products = $this->product->pluck('name', 'id')->toArray(); |
||
| 362 | $periods = $this->period->pluck('name', 'days')->toArray(); |
||
| 363 | $url = $this->GetMyUrl(); |
||
| 364 | $cartUrl = $url.'/cart?id='.$id; |
||
| 365 | $product = $this->product->where('id', $id)->first(); |
||
| 366 | $taxes = $this->tax_class->pluck('name', 'id')->toArray(); |
||
| 367 | // dd($taxes); |
||
| 368 | $saved_taxes = $this->tax_relation->where('product_id', $id)->get(); |
||
| 369 | $savedTaxes = $this->tax_relation->where('product_id', $id)->pluck('tax_class_id')->toArray(); |
||
| 370 | |||
| 371 | return view('themes.default1.product.product.edit', |
||
| 372 | compact('product', 'periods', 'type', 'subscription', |
||
| 373 | 'currency', 'group', 'price', 'cartUrl', 'products', |
||
| 374 | 'regular', 'sales', 'taxes', 'saved_taxes', 'savedTaxes')); |
||
| 375 | } catch (\Exception $e) { |
||
| 376 | Bugsnag::notifyException($e); |
||
| 377 | |||
| 378 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 379 | } |
||
| 380 | } |
||
| 381 | |||
| 382 | /** |
||
| 383 | * Update the specified resource in storage. |
||
| 384 | * |
||
| 385 | * @param int $id |
||
| 386 | * |
||
| 387 | * @return \Response |
||
| 388 | */ |
||
| 389 | public function update($id, Request $request) |
||
| 390 | { |
||
| 391 | $input = $request->all(); |
||
| 392 | $v = \Validator::make($input, [ |
||
| 393 | 'name' => 'required', |
||
| 394 | 'type' => 'required', |
||
| 395 | 'group' => 'required', |
||
| 396 | 'image' => 'sometimes | mimes:jpeg,jpg,png,gif | max:1000', |
||
| 397 | ]); |
||
| 398 | |||
| 399 | if ($v->fails()) { |
||
| 400 | return redirect()->back()->with('errors', $v->errors()); |
||
| 401 | } |
||
| 402 | |||
| 403 | try { |
||
| 404 | $product = $this->product->where('id', $id)->first(); |
||
| 405 | if ($request->hasFile('image')) { |
||
| 406 | $image = $request->file('image')->getClientOriginalName(); |
||
| 407 | $imagedestinationPath = 'dist/product/images'; |
||
| 408 | $request->file('image')->move($imagedestinationPath, $image); |
||
| 409 | $product->image = $image; |
||
| 410 | } |
||
| 411 | if ($request->hasFile('file')) { |
||
| 412 | $file = $request->file('file')->getClientOriginalName(); |
||
| 413 | $filedestinationPath = storage_path().'/products'; |
||
| 414 | $request->file('file')->move($filedestinationPath, $file); |
||
| 415 | $product->file = $file; |
||
| 416 | } |
||
| 417 | $product->fill($request->except('image', 'file'))->save(); |
||
| 418 | $this->updateVersionFromGithub($product->id); |
||
| 419 | |||
| 420 | $product_id = $product->id; |
||
| 421 | $subscription = $request->input('subscription'); |
||
| 422 | $cost = $request->input('price'); |
||
| 423 | $sales_price = $request->input('sales_price'); |
||
| 424 | $currencies = $request->input('currency'); |
||
| 425 | |||
| 426 | //add tax class to tax_product_relation table |
||
| 427 | $taxes = $request->input('tax'); |
||
| 428 | $newTax = $this->saveTax($taxes, $product_id); |
||
| 429 | return redirect()->back()->with('success', \Lang::get('message.updated-successfully')); |
||
| 430 | } catch (\Exception $e) { |
||
| 431 | Bugsnag::notifyException($e); |
||
| 432 | |||
| 433 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 434 | } |
||
| 435 | } |
||
| 436 | |||
| 437 | public function saveTax($taxes, $product_id) |
||
| 438 | { |
||
| 439 | if ($taxes) { |
||
| 440 | |||
| 441 | $this->tax_relation->where('product_id', $product_id)->delete(); |
||
| 442 | foreach ($taxes as $tax) { |
||
| 443 | $newTax = new TaxProductRelation(); |
||
| 444 | $newTax->product_id = $product_id; |
||
| 445 | $newTax->tax_class_id = $tax; |
||
| 446 | $newTax->save(); |
||
| 447 | } |
||
| 448 | } |
||
| 449 | return $newTax; |
||
| 450 | } |
||
| 451 | |||
| 452 | /** |
||
| 453 | * Remove the specified resource from storage. |
||
| 454 | * |
||
| 455 | * @param int $id |
||
| 456 | * |
||
| 457 | * @return \Response |
||
| 458 | */ |
||
| 459 | public function destroy(Request $request) |
||
| 460 | { |
||
| 461 | try { |
||
| 462 | $ids = $request->input('select'); |
||
| 463 | if (!empty($ids)) { |
||
| 464 | foreach ($ids as $id) { |
||
| 465 | if ($id != 1) { |
||
| 466 | $product = $this->product->where('id', $id)->first(); |
||
| 467 | if ($product) { |
||
| 468 | $product->delete(); |
||
| 469 | } else { |
||
| 470 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 471 | <i class='fa fa-ban'></i> |
||
| 472 | <b>"./* @scrutinizer ignore-type */\Lang::get('message.alert').'!</b> '. |
||
| 473 | /* @scrutinizer ignore-type */\Lang::get('message.failed').' |
||
| 474 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 475 | './* @scrutinizer ignore-type */\Lang::get('message.no-record').' |
||
| 476 | </div>'; |
||
| 477 | //echo \Lang::get('message.no-record') . ' [id=>' . $id . ']'; |
||
| 478 | } |
||
| 479 | echo "<div class='alert alert-success alert-dismissable'> |
||
| 480 | <i class='fa fa-ban'></i> |
||
| 481 | <b>"./* @scrutinizer ignore-type */ |
||
| 482 | \Lang::get('message.alert').'!</b> './* @scrutinizer ignore-type */ \Lang::get('message.success').' |
||
| 483 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 484 | './* @scrutinizer ignore-type */\Lang::get('message.deleted-successfully').' |
||
| 485 | </div>'; |
||
| 486 | } else { |
||
| 487 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 488 | <i class='fa fa-ban'></i> |
||
| 489 | <b>"./* @scrutinizer ignore-type */\Lang::get('message.alert').'!</b> '. |
||
| 490 | /* @scrutinizer ignore-type */\Lang::get('message.failed').' |
||
| 491 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 492 | './* @scrutinizer ignore-type */ \Lang::get('message.can-not-delete-default').' |
||
| 493 | </div>'; |
||
| 494 | } |
||
| 495 | } |
||
| 496 | } else { |
||
| 497 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 498 | <i class='fa fa-ban'></i> |
||
| 499 | <b>"./* @scrutinizer ignore-type */\Lang::get('message.alert').'!</b> '. |
||
| 500 | /* @scrutinizer ignore-type */\Lang::get('message.failed').' |
||
| 501 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 502 | './* @scrutinizer ignore-type */\Lang::get('message.select-a-row').' |
||
| 503 | </div>'; |
||
| 504 | //echo \Lang::get('message.select-a-row'); |
||
| 505 | } |
||
| 506 | $lastActivity = Activity::all()->last(); |
||
| 507 | } catch (\Exception $e) { |
||
| 508 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 509 | <i class='fa fa-ban'></i> |
||
| 510 | <b>"./* @scrutinizer ignore-type */\Lang::get('message.alert').'!</b> '. |
||
| 511 | /* @scrutinizer ignore-type */\Lang::get('message.failed').' |
||
| 512 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 513 | '.$e->getMessage().' |
||
| 514 | </div>'; |
||
| 515 | } |
||
| 516 | } |
||
| 517 | |||
| 518 | /** |
||
| 519 | * Remove the specified resource from storage. |
||
| 520 | * |
||
| 521 | * @param int $id |
||
| 522 | * |
||
| 523 | * @return Response |
||
| 524 | */ |
||
| 525 | public function fileDestroy(Request $request) |
||
| 526 | { |
||
| 527 | try { |
||
| 528 | $ids = $request->input('select'); |
||
| 529 | if (!empty($ids)) { |
||
| 530 | foreach ($ids as $id) { |
||
| 531 | if ($id != 1) { |
||
| 532 | $product = $this->product_upload->where('id', $id)->first(); |
||
| 533 | if ($product) { |
||
| 534 | $product->delete(); |
||
| 535 | } else { |
||
| 536 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 537 | <i class='fa fa-ban'></i> |
||
| 538 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.failed').' |
||
| 539 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 540 | '.\Lang::get('message.no-record').' |
||
| 541 | </div>'; |
||
| 542 | //echo \Lang::get('message.no-record') . ' [id=>' . $id . ']'; |
||
| 543 | } |
||
| 544 | echo "<div class='alert alert-success alert-dismissable'> |
||
| 545 | <i class='fa fa-ban'></i> |
||
| 546 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.success').' |
||
| 547 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 548 | '.\Lang::get('message.deleted-successfully').' |
||
| 549 | </div>'; |
||
| 550 | } else { |
||
| 551 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 552 | <i class='fa fa-ban'></i> |
||
| 553 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.failed').' |
||
| 554 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 555 | '.\Lang::get('message.can-not-delete-default').' |
||
| 556 | </div>'; |
||
| 557 | } |
||
| 558 | } |
||
| 559 | } else { |
||
| 560 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 561 | <i class='fa fa-ban'></i> |
||
| 562 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.failed').' |
||
| 563 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 564 | '.\Lang::get('message.select-a-row').' |
||
| 565 | </div>'; |
||
| 566 | //echo \Lang::get('message.select-a-row'); |
||
| 567 | } |
||
| 568 | } catch (\Exception $e) { |
||
| 569 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 570 | <i class='fa fa-ban'></i> |
||
| 571 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.failed').' |
||
| 572 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 573 | '.$e->getMessage().' |
||
| 574 | </div>'; |
||
| 575 | } |
||
| 576 | } |
||
| 577 | |||
| 578 | |||
| 579 | /* |
||
| 580 | * Download Files from Filesystem/Github |
||
| 581 | */ |
||
| 582 | public function downloadProduct($uploadid, $id, $invoice_id, $version_id = '') |
||
| 583 | { |
||
| 584 | try { |
||
| 585 | $product = $this->product->findOrFail($uploadid); |
||
| 586 | $type = $product->type; |
||
| 587 | $owner = $product->github_owner; |
||
| 588 | $repository = $product->github_repository; |
||
| 589 | $file = $this->product_upload |
||
| 590 | ->where('product_id', '=', $uploadid) |
||
| 591 | ->where('id', $version_id)->select('file')->first(); |
||
| 592 | $order = Order::where('invoice_id', '=', $invoice_id)->first(); |
||
| 593 | $order_id = $order->id; |
||
| 594 | if ($type == 2) { |
||
| 595 | $relese = $this->getRelease($owner, $repository, $order_id, $file); |
||
| 596 | |||
| 597 | return $relese; |
||
| 598 | } |
||
| 599 | } catch (\Exception $e) { |
||
| 600 | Bugsnag::notifyException($e); |
||
| 601 | |||
| 602 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 603 | } |
||
| 604 | } |
||
| 605 | |||
| 606 | public function adminDownload($id, $invoice = '', $api = false) |
||
| 607 | { |
||
| 608 | try { |
||
| 609 | $role = \Auth::user()->role; |
||
| 610 | $release = $this->getLinkToDownload($role, $invoice, $id); |
||
| 611 | |||
| 612 | if (is_array($release) && array_key_exists('type', $release)) { |
||
| 613 | header('Location: '.$release['release']); |
||
| 614 | exit; |
||
| 615 | } else { |
||
| 616 | header('Content-type: Zip'); |
||
| 617 | header('Content-Description: File Transfer'); |
||
| 618 | header('Content-Disposition: attachment; filename=Faveo.zip'); |
||
| 619 | header('Content-Length: '.filesize($release)); |
||
| 620 | flush(); |
||
| 621 | readfile("$release"); |
||
| 622 | } |
||
| 623 | } catch (\Exception $e) { |
||
| 624 | if ($api) { |
||
| 625 | return response()->json(['error'=>$e->getMessage()]); |
||
| 626 | } |
||
| 627 | Bugsnag::notifyException($e); |
||
| 628 | |||
| 629 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 630 | } |
||
| 631 | } |
||
| 632 | |||
| 633 | public function getProductField($productid) |
||
| 634 | { |
||
| 635 | try { |
||
| 636 | $field = ''; |
||
| 637 | $product = $this->product->find($productid); |
||
| 638 | if ($product) { |
||
| 639 | if ($product->require_domain == 1) { |
||
| 640 | $field .= "<div class='col-md-4 form-group'> |
||
| 641 | <label class='required'>"./* @scrutinizer ignore-type */ |
||
| 642 | \Lang::get('message.domain')."</label> |
||
| 643 | <input type='text' name='domain' class='form-control' |
||
| 644 | id='domain' placeholder='http://example.com'> |
||
| 645 | </div>"; |
||
| 646 | } |
||
| 647 | } |
||
| 648 | |||
| 649 | return $field; |
||
| 650 | } catch (\Exception $ex) { |
||
| 651 | Bugsnag::notifyException($ex); |
||
| 652 | |||
| 653 | return $ex->getMessage(); |
||
| 654 | } |
||
| 655 | } |
||
| 656 | |||
| 657 | public function getSubscriptionCheckScript() |
||
| 672 | data: {'product': val, 'user': user,'plan':plan}, |
||
| 673 | //data: 'product=' + val+'user='+user, |
||
| 674 | success: function (data) { |
||
| 675 | var price = data['price']; |
||
| 676 | var field = data['field']; |
||
| 677 | $('#price').val(price); |
||
| 678 | $('#fields').append(field); |
||
| 679 | } |
||
| 680 | }); |
||
| 686 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.