DJController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php namespace WITR\Http\Controllers;
2
3
use WITR\Http\Requests;
4
use WITR\Http\Requests\DJ\TicketRequest;
5
use WITR\Http\Controllers\Controller;
6
use WITR\Services\IcecastReader;
7
use WITR\TopTwenty\Reader as WeeklyChart;
8
use Illuminate\Contracts\Filesystem\Factory as Storage;
9
use Illuminate\Contracts\Mail\Mailer;
10
use WITR\SystemSetting;
11
12
use Illuminate\Http\Request;
13
14
class DJController extends Controller {
15
16
	public function __construct()
17
	{
18
		$this->middleware('dj');
19
	}
20
21
	public function index()
22
	{
23
		$workHoursForm = SystemSetting::djHoursFormLocation()->value;
0 ignored issues
show
Bug introduced by
The method djHoursFormLocation() does not exist on WITR\SystemSetting. Did you maybe mean scopeDjHoursFormLocation()?

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...
24
		$cdSignoutForm = SystemSetting::cdSignoutFormLocation()->value;
0 ignored issues
show
Bug introduced by
The method cdSignoutFormLocation() does not exist on WITR\SystemSetting. Did you maybe mean scopeCdSignoutFormLocation()?

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...
25
		return view('dj.index', compact('workHoursForm', 'cdSignoutForm'));
26
	}
27
28
	public function listeners(IcecastReader $icecast, $studio = 'studio-x')
29
	{
30
		$listeners = $icecast->get($studio);
31
		return view('dj.listeners', compact('listeners', 'studio'));
32
	}
33
34
	public function fetchFile(Storage $storage, $file)
35
	{
36
		if (!$storage->exists($file))
0 ignored issues
show
Bug introduced by
The method exists() does not seem to exist on object<Illuminate\Contracts\Filesystem\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
		{
38
			return abort(404);
39
		}
40
		$locationRoot = $storage->getDriver()->getAdapter()->getPathPrefix();
0 ignored issues
show
Bug introduced by
The method getDriver() does not seem to exist on object<Illuminate\Contracts\Filesystem\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
		return response()->download($locationRoot . $file);
42
	}
43
44
	public function ticketForm()
45
	{
46
		return view('dj.ticket');
47
	}
48
49 View Code Duplication
	public function submitTicket(Mailer $mailer, TicketRequest $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...
50
	{
51
		$ticketRecipient = app('config')['witr.ticket_recipient'];
52
		$mailer->send('emails.support_ticket', $request->all(), function($message) use ($ticketRecipient)
53
		{
54
			$message->to($ticketRecipient['email'], $ticketRecipient['name'])
55
					->subject('WITR Support Ticket');
56
		});
57
58
		return redirect()->route('dj.index')
59
			->with('success', 'Support Ticket Submitted!');
60
	}
61
62
	public function topWeek(WeeklyChart $chart)
63
	{
64
		$tracks = $chart->getWeek();
65
		return view('dj.chart', compact('tracks'));
66
	}
67
}
68