Completed
Pull Request — master (#30)
by Manuel
05:30
created
app/Exceptions/Handler.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -8,61 +8,61 @@
 block discarded – undo
8 8
 
9 9
 class Handler extends ExceptionHandler
10 10
 {
11
-    /**
12
-     * A list of the exception types that should not be reported.
13
-     *
14
-     * @var array
15
-     */
16
-    protected $dontReport = [
17
-        \Illuminate\Auth\AuthenticationException::class,
18
-        \Illuminate\Auth\Access\AuthorizationException::class,
19
-        \Symfony\Component\HttpKernel\Exception\HttpException::class,
20
-        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
21
-        \Illuminate\Session\TokenMismatchException::class,
22
-        \Illuminate\Validation\ValidationException::class,
23
-    ];
11
+	/**
12
+	 * A list of the exception types that should not be reported.
13
+	 *
14
+	 * @var array
15
+	 */
16
+	protected $dontReport = [
17
+		\Illuminate\Auth\AuthenticationException::class,
18
+		\Illuminate\Auth\Access\AuthorizationException::class,
19
+		\Symfony\Component\HttpKernel\Exception\HttpException::class,
20
+		\Illuminate\Database\Eloquent\ModelNotFoundException::class,
21
+		\Illuminate\Session\TokenMismatchException::class,
22
+		\Illuminate\Validation\ValidationException::class,
23
+	];
24 24
 
25
-    /**
26
-     * Report or log an exception.
27
-     *
28
-     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
29
-     *
30
-     * @param \Exception $exception
31
-     *
32
-     * @return void
33
-     */
34
-    public function report(Exception $exception)
35
-    {
36
-        parent::report($exception);
37
-    }
25
+	/**
26
+	 * Report or log an exception.
27
+	 *
28
+	 * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
29
+	 *
30
+	 * @param \Exception $exception
31
+	 *
32
+	 * @return void
33
+	 */
34
+	public function report(Exception $exception)
35
+	{
36
+		parent::report($exception);
37
+	}
38 38
 
39
-    /**
40
-     * Render an exception into an HTTP response.
41
-     *
42
-     * @param \Illuminate\Http\Request $request
43
-     * @param \Exception               $exception
44
-     *
45
-     * @return \Illuminate\Http\Response
46
-     */
47
-    public function render($request, Exception $exception)
48
-    {
49
-        return parent::render($request, $exception);
50
-    }
39
+	/**
40
+	 * Render an exception into an HTTP response.
41
+	 *
42
+	 * @param \Illuminate\Http\Request $request
43
+	 * @param \Exception               $exception
44
+	 *
45
+	 * @return \Illuminate\Http\Response
46
+	 */
47
+	public function render($request, Exception $exception)
48
+	{
49
+		return parent::render($request, $exception);
50
+	}
51 51
 
52
-    /**
53
-     * Convert an authentication exception into an unauthenticated response.
54
-     *
55
-     * @param \Illuminate\Http\Request                 $request
56
-     * @param \Illuminate\Auth\AuthenticationException $exception
57
-     *
58
-     * @return \Illuminate\Http\Response
59
-     */
60
-    protected function unauthenticated($request, AuthenticationException $exception)
61
-    {
62
-        if ($request->expectsJson()) {
63
-            return response()->json(['error' => 'Unauthenticated.'], 401);
64
-        }
52
+	/**
53
+	 * Convert an authentication exception into an unauthenticated response.
54
+	 *
55
+	 * @param \Illuminate\Http\Request                 $request
56
+	 * @param \Illuminate\Auth\AuthenticationException $exception
57
+	 *
58
+	 * @return \Illuminate\Http\Response
59
+	 */
60
+	protected function unauthenticated($request, AuthenticationException $exception)
61
+	{
62
+		if ($request->expectsJson()) {
63
+			return response()->json(['error' => 'Unauthenticated.'], 401);
64
+		}
65 65
 
66
-        return redirect()->guest('login');
67
-    }
66
+		return redirect()->guest('login');
67
+	}
68 68
 }
Please login to merge, or discard this patch.
app/Http/Controllers/Api/ApiController.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -7,102 +7,102 @@
 block discarded – undo
7 7
 
8 8
 class ApiController extends Controller
9 9
 {
10
-    /**
11
-     * Default Status Code.
12
-     *
13
-     * @var int
14
-     */
15
-    protected $statusCode = 200;
10
+	/**
11
+	 * Default Status Code.
12
+	 *
13
+	 * @var int
14
+	 */
15
+	protected $statusCode = 200;
16 16
 
17
-    /**
18
-     * @return int
19
-     */
20
-    public function getStatusCode()
21
-    {
22
-        return $this->statusCode;
23
-    }
17
+	/**
18
+	 * @return int
19
+	 */
20
+	public function getStatusCode()
21
+	{
22
+		return $this->statusCode;
23
+	}
24 24
 
25
-    /**
26
-     * @param int $statusCode
27
-     *
28
-     * @return $this
29
-     */
30
-    public function setStatusCode($statusCode)
31
-    {
32
-        $this->statusCode = $statusCode;
25
+	/**
26
+	 * @param int $statusCode
27
+	 *
28
+	 * @return $this
29
+	 */
30
+	public function setStatusCode($statusCode)
31
+	{
32
+		$this->statusCode = $statusCode;
33 33
 
34
-        return $this;
35
-    }
34
+		return $this;
35
+	}
36 36
 
37
-    /**
38
-     * @param array $data
39
-     *
40
-     * @return mixed
41
-     */
42
-    public function respondCreated($data, $id)
43
-    {
44
-        $headers = [
45
-            'Location' => route('devices.show', $id),
46
-        ];
37
+	/**
38
+	 * @param array $data
39
+	 *
40
+	 * @return mixed
41
+	 */
42
+	public function respondCreated($data, $id)
43
+	{
44
+		$headers = [
45
+			'Location' => route('devices.show', $id),
46
+		];
47 47
 
48
-        return $this->setStatusCode(201)->respond(compact('data'), $headers);
49
-    }
48
+		return $this->setStatusCode(201)->respond(compact('data'), $headers);
49
+	}
50 50
 
51
-    /**
52
-     * @param array $data
53
-     *
54
-     * @return mixed
55
-     */
56
-    public function respondPoked($data, $id)
57
-    {
58
-        $headers = [
59
-            'Location' => route('devices.show', $id),
60
-        ];
51
+	/**
52
+	 * @param array $data
53
+	 *
54
+	 * @return mixed
55
+	 */
56
+	public function respondPoked($data, $id)
57
+	{
58
+		$headers = [
59
+			'Location' => route('devices.show', $id),
60
+		];
61 61
 
62
-        return $this->setStatusCode(200)->respond(compact('data'), $headers);
63
-    }
62
+		return $this->setStatusCode(200)->respond(compact('data'), $headers);
63
+	}
64 64
 
65
-    /**
66
-     * @return mixed
67
-     */
68
-    public function respondNoContent()
69
-    {
70
-        return $this->setStatusCode(204)->respond([]);
71
-    }
65
+	/**
66
+	 * @return mixed
67
+	 */
68
+	public function respondNoContent()
69
+	{
70
+		return $this->setStatusCode(204)->respond([]);
71
+	}
72 72
 
73
-    /**
74
-     * @param string $message
75
-     *
76
-     * @return mixed
77
-     */
78
-    public function respondNotFound($message = 'Did not find the resource you are looking for!')
79
-    {
80
-        return $this->setStatusCode(404)->respondWithError($message);
81
-    }
73
+	/**
74
+	 * @param string $message
75
+	 *
76
+	 * @return mixed
77
+	 */
78
+	public function respondNotFound($message = 'Did not find the resource you are looking for!')
79
+	{
80
+		return $this->setStatusCode(404)->respondWithError($message);
81
+	}
82 82
 
83
-    /**
84
-     * @param $data
85
-     * @param array $headers
86
-     *
87
-     * @return mixed
88
-     */
89
-    public function respond($data, $headers = [])
90
-    {
91
-        return Response::json($data, $this->getStatusCode(), $headers);
92
-    }
83
+	/**
84
+	 * @param $data
85
+	 * @param array $headers
86
+	 *
87
+	 * @return mixed
88
+	 */
89
+	public function respond($data, $headers = [])
90
+	{
91
+		return Response::json($data, $this->getStatusCode(), $headers);
92
+	}
93 93
 
94
-    /**
95
-     * @param $message
96
-     *
97
-     * @return mixed
98
-     */
99
-    public function respondWithError($message)
100
-    {
101
-        return $this->respond([
102
-            'errors' => [
103
-                'title'  => $message,
104
-                'status' => $this->getStatusCode(),
105
-            ],
106
-        ]);
107
-    }
94
+	/**
95
+	 * @param $message
96
+	 *
97
+	 * @return mixed
98
+	 */
99
+	public function respondWithError($message)
100
+	{
101
+		return $this->respond([
102
+			'errors' => [
103
+				'title'  => $message,
104
+				'status' => $this->getStatusCode(),
105
+			],
106
+		]);
107
+	}
108 108
 }
Please login to merge, or discard this patch.
app/User.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@
 block discarded – undo
7 7
 
8 8
 class User extends Authenticatable
9 9
 {
10
-    use Notifiable;
10
+	use Notifiable;
11 11
 
12
-    /**
13
-     * The attributes that are mass assignable.
14
-     *
15
-     * @var array
16
-     */
17
-    protected $fillable = [
18
-        'name', 'email', 'password',
19
-    ];
12
+	/**
13
+	 * The attributes that are mass assignable.
14
+	 *
15
+	 * @var array
16
+	 */
17
+	protected $fillable = [
18
+		'name', 'email', 'password',
19
+	];
20 20
 
21
-    /**
22
-     * The attributes that should be hidden for arrays.
23
-     *
24
-     * @var array
25
-     */
26
-    protected $hidden = [
27
-        'password', 'remember_token',
28
-    ];
21
+	/**
22
+	 * The attributes that should be hidden for arrays.
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected $hidden = [
27
+		'password', 'remember_token',
28
+	];
29 29
 }
Please login to merge, or discard this patch.
app/Services/Registrar.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@
 block discarded – undo
8 8
 
9 9
 class Registrar
10 10
 {
11
-    use RegistersUsers;
11
+	use RegistersUsers;
12 12
 
13
-    /**
14
-     * Get a validator for an incoming registration request.
15
-     *
16
-     * @param array $data
17
-     *
18
-     * @return \Illuminate\Contracts\Validation\Validator
19
-     */
20
-    public function validator(array $data)
21
-    {
22
-        return Validator::make($data, [
23
-            'email'    => 'required|email|max:255|unique:users',
24
-            'password' => 'required|confirmed|min:6',
25
-        ]);
26
-    }
13
+	/**
14
+	 * Get a validator for an incoming registration request.
15
+	 *
16
+	 * @param array $data
17
+	 *
18
+	 * @return \Illuminate\Contracts\Validation\Validator
19
+	 */
20
+	public function validator(array $data)
21
+	{
22
+		return Validator::make($data, [
23
+			'email'    => 'required|email|max:255|unique:users',
24
+			'password' => 'required|confirmed|min:6',
25
+		]);
26
+	}
27 27
 
28
-    /**
29
-     * Create a new user instance after a valid registration.
30
-     *
31
-     * @param array $data
32
-     *
33
-     * @return User
34
-     */
35
-    public function create(array $data)
36
-    {
37
-        return User::create([
38
-            'email'    => $data['email'],
39
-            'password' => bcrypt($data['password']),
40
-        ]);
41
-    }
28
+	/**
29
+	 * Create a new user instance after a valid registration.
30
+	 *
31
+	 * @param array $data
32
+	 *
33
+	 * @return User
34
+	 */
35
+	public function create(array $data)
36
+	{
37
+		return User::create([
38
+			'email'    => $data['email'],
39
+			'password' => bcrypt($data['password']),
40
+		]);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
app/DeviceArchive.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 class DeviceArchive extends Model
8 8
 {
9
-    protected $table = 'device_archive';
9
+	protected $table = 'device_archive';
10 10
 
11
-    protected $guarded = [];
11
+	protected $guarded = [];
12 12
 }
Please login to merge, or discard this patch.
app/Handlers/Events/UpdateStatistics.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,29 +11,29 @@
 block discarded – undo
11 11
 
12 12
 class UpdateStatistics
13 13
 {
14
-    /**
15
-     * Handle the event.
16
-     *
17
-     * @param ServerWasPoked $event
18
-     *
19
-     * @return void
20
-     */
21
-    public function handle(ServerWasPoked $event)
22
-    {
23
-        $device = $event->getDevice()->toArray();
14
+	/**
15
+	 * Handle the event.
16
+	 *
17
+	 * @param ServerWasPoked $event
18
+	 *
19
+	 * @return void
20
+	 */
21
+	public function handle(ServerWasPoked $event)
22
+	{
23
+		$device = $event->getDevice()->toArray();
24 24
 
25
-        // device count
26
-        DeviceArchive::updateOrCreate(
27
-            ['mac_hash' => md5($device['mac'])],
28
-            ['updated_at' => Carbon::now()]
29
-        );
25
+		// device count
26
+		DeviceArchive::updateOrCreate(
27
+			['mac_hash' => md5($device['mac'])],
28
+			['updated_at' => Carbon::now()]
29
+		);
30 30
 
31
-        // network distribution
32
-        $network = ExtractNetwork::fromIp($device['ip']);
33
-        DB::table('network_distribution')->where('network', $network)->increment('pokes');
31
+		// network distribution
32
+		$network = ExtractNetwork::fromIp($device['ip']);
33
+		DB::table('network_distribution')->where('network', $network)->increment('pokes');
34 34
 
35
-        // pokes
36
-        $date = Carbon::now()->toDateString();
37
-        Poke::firstOrCreate(['date' => $date])->increment('pokes');
38
-    }
35
+		// pokes
36
+		$date = Carbon::now()->toDateString();
37
+		Poke::firstOrCreate(['date' => $date])->increment('pokes');
38
+	}
39 39
 }
Please login to merge, or discard this patch.
app/Poke.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 class Poke extends Model
8 8
 {
9
-    protected $guarded = [];
9
+	protected $guarded = [];
10 10
 
11
-    public $timestamps = false;
11
+	public $timestamps = false;
12 12
 }
Please login to merge, or discard this patch.
app/Services/Statistics.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -9,60 +9,60 @@
 block discarded – undo
9 9
 
10 10
 class Statistics
11 11
 {
12
-    /**
13
-     * Returns the count of all pokes.
14
-     *
15
-     * @return mixed
16
-     */
17
-    public function totalPokes()
18
-    {
19
-        $base = 189771;
12
+	/**
13
+	 * Returns the count of all pokes.
14
+	 *
15
+	 * @return mixed
16
+	 */
17
+	public function totalPokes()
18
+	{
19
+		$base = 189771;
20 20
 
21
-        return DB::table('network_distribution')->sum('pokes') + $base;
22
-    }
21
+		return DB::table('network_distribution')->sum('pokes') + $base;
22
+	}
23 23
 
24
-    /**
25
-     * Returns the the count of all devices.
26
-     *
27
-     * @return mixed
28
-     */
29
-    public function totalDevices()
30
-    {
31
-        return DeviceArchive::count();
32
-    }
24
+	/**
25
+	 * Returns the the count of all devices.
26
+	 *
27
+	 * @return mixed
28
+	 */
29
+	public function totalDevices()
30
+	{
31
+		return DeviceArchive::count();
32
+	}
33 33
 
34
-    /**
35
-     * Returns all pokes.
36
-     *
37
-     * @return mixed
38
-     */
39
-    public function allPokes()
40
-    {
41
-        return Poke::all();
42
-    }
34
+	/**
35
+	 * Returns all pokes.
36
+	 *
37
+	 * @return mixed
38
+	 */
39
+	public function allPokes()
40
+	{
41
+		return Poke::all();
42
+	}
43 43
 
44
-    /**
45
-     * Returns a collection of all networks and it's count.
46
-     *
47
-     * @return mixed
48
-     */
49
-    public function networkDistribution()
50
-    {
51
-        $data = DB::table('network_distribution')
52
-            ->select('network as label', 'pokes as value')
53
-            ->get();
44
+	/**
45
+	 * Returns a collection of all networks and it's count.
46
+	 *
47
+	 * @return mixed
48
+	 */
49
+	public function networkDistribution()
50
+	{
51
+		$data = DB::table('network_distribution')
52
+			->select('network as label', 'pokes as value')
53
+			->get();
54 54
 
55
-        return $this->addColors($data);
56
-    }
55
+		return $this->addColors($data);
56
+	}
57 57
 
58
-    private function addColors($data)
59
-    {
60
-        $colors = ['rgb(23,103,153)', 'rgb(47,135,176)', 'rgb(66,164,187)', 'rgb(91,192,196)'];
61
-        $highlight_colors = ['#8BB3CC', '#97C3D7', '#ADDFE1', '#BBEAE3'];
58
+	private function addColors($data)
59
+	{
60
+		$colors = ['rgb(23,103,153)', 'rgb(47,135,176)', 'rgb(66,164,187)', 'rgb(91,192,196)'];
61
+		$highlight_colors = ['#8BB3CC', '#97C3D7', '#ADDFE1', '#BBEAE3'];
62 62
 
63
-        return $data->each(function ($network, $i) use ($colors, $highlight_colors) {
64
-            $network->color = $colors[$i];
65
-            $network->highlight = $highlight_colors[$i];
66
-        });
67
-    }
63
+		return $data->each(function ($network, $i) use ($colors, $highlight_colors) {
64
+			$network->color = $colors[$i];
65
+			$network->highlight = $highlight_colors[$i];
66
+		});
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
         $colors = ['rgb(23,103,153)', 'rgb(47,135,176)', 'rgb(66,164,187)', 'rgb(91,192,196)'];
61 61
         $highlight_colors = ['#8BB3CC', '#97C3D7', '#ADDFE1', '#BBEAE3'];
62 62
 
63
-        return $data->each(function ($network, $i) use ($colors, $highlight_colors) {
63
+        return $data->each(function($network, $i) use ($colors, $highlight_colors) {
64 64
             $network->color = $colors[$i];
65 65
             $network->highlight = $highlight_colors[$i];
66 66
         });
Please login to merge, or discard this patch.
app/Utilities/ExtractNetwork.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,27 +4,27 @@
 block discarded – undo
4 4
 
5 5
 class ExtractNetwork
6 6
 {
7
-    /**
8
-     * Extract the network from the ip address.
9
-     *
10
-     * @param string $ip
11
-     *
12
-     * @return string $network
13
-     */
14
-    public static function fromIp($ip)
15
-    {
16
-        if (starts_with($ip, '192.168.')) {
17
-            return '192.168.0.0/16';
18
-        }
7
+	/**
8
+	 * Extract the network from the ip address.
9
+	 *
10
+	 * @param string $ip
11
+	 *
12
+	 * @return string $network
13
+	 */
14
+	public static function fromIp($ip)
15
+	{
16
+		if (starts_with($ip, '192.168.')) {
17
+			return '192.168.0.0/16';
18
+		}
19 19
 
20
-        if (starts_with($ip, '10.')) {
21
-            return '10.0.0.0/8';
22
-        }
20
+		if (starts_with($ip, '10.')) {
21
+			return '10.0.0.0/8';
22
+		}
23 23
 
24
-        if (preg_match('/^172\.(1[6-9]|2[0-9]|3[01])\./', $ip)) {
25
-            return '172.16.0.0/12';
26
-        }
24
+		if (preg_match('/^172\.(1[6-9]|2[0-9]|3[01])\./', $ip)) {
25
+			return '172.16.0.0/12';
26
+		}
27 27
 
28
-        return 'Internet';
29
-    }
28
+		return 'Internet';
29
+	}
30 30
 }
Please login to merge, or discard this patch.