AskDestlerController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 57.14 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 5
dl 12
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 5 1
A submit() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace WITR\Http\Controllers;
2
3
use WITR\Http\Requests\AskDestlerRequest;
4
use WITR\Http\Controllers\Controller;
5
use Illuminate\Contracts\Mail\Mailer;
6
use WITR\SystemSetting;
7
8
use Illuminate\Http\Request;
9
10
class AskDestlerController extends Controller {
11
12
	public function index()
13
	{
14
		$destlerText = SystemSetting::askDestlerText();
0 ignored issues
show
Bug introduced by
The method askDestlerText() does not exist on WITR\SystemSetting. Did you maybe mean scopeAskDestlerText()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
15
		return view('askdestler.index', ['destlerText' => $destlerText]);
16
	}
17
18 View Code Duplication
	public function submit(Mailer $mailer, AskDestlerRequest $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
	{
20
		$askdestlerRecipient = app('config')['witr.askdestler_recipient'];
21
		$mailer->send('emails.askdestler', $request->all(), function($message) use ($askdestlerRecipient)
22
		{
23
			$message->to($askdestlerRecipient['email'], $askdestlerRecipient['name'])
24
					->subject('WITR Ask Destler Submission');
25
		});
26
27
		return redirect()->route('askdestler')
28
			->with('success', 'Question Submitted!');
29
	}
30
}
31