AuthViewComposer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A compose() 0 6 1
1
<?php
2
3
namespace WITR\ViewComposers;
4
5
use Illuminate\Http\Request;
6
use Illuminate\View\View;
7
use Illuminate\Contracts\Auth\Guard;
8
use WITR\Services\Whitelist;
9
10
class AuthViewComposer {
11
12
	protected $auth;
13
	protected $whitelist;
14
	protected $request;
15
16
	public function __construct(Guard $auth, Whitelist $whitelist, Request $request)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
17
	{
18
		$this->auth = $auth;
19
		$this->whitelist = $whitelist;
20
		$this->request = $request;
21
	}
22
23
	/**
24
	 * Bind data to the view.
25
	 *
26
	 * @param  View  $view
27
	 * @return void
28
	 */
29
	public function compose(View $view)
30
	{
31
		$view->with('user', $this->auth->user())
32
			 ->with('authenticated', $this->auth->check())
33
			 ->with('in_station', $this->whitelist->inRange($this->request));
34
	}
35
}