Completed
Push — master ( 5049fe...5fd7f0 )
by Sherif
02:43
created

ErrorHandler::invalidResetToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php namespace App\Modules\V1\Core\Utl;
2
3
class ErrorHandler
4
{
5
    public function unAuthorized()
6
    {
7
        $error = ['status' => 401, 'message' => 'Please login before any action'];
8
        abort($error['status'], $error['message']);
9
    }
10
11
    public function tokenExpired()
12
    {
13
        $error = ['status' => 403, 'message' => 'Login token expired'];
14
        abort($error['status'], $error['message']);
15
    }
16
17
     public function noPermissions()
18
    {
19
        $error = ['status' => 403, 'message' => 'No permissions'];
20
        abort($error['status'], $error['message']);
21
    }
22
23
    public function loginFailed()
24
    {
25
        $error = ['status' => 400, 'message' => 'Wrong mail or password'];
26
        abort($error['status'], $error['message']);
27
    }
28
29
    public function redisNotRunning()
30
    {
31
        $error = ['status' => 400, 'message' => 'Your redis notification server isn\'t running'];
32
        abort($error['status'], $error['message']);
33
    }
34
35
    public function dbQueryError()
36
    {
37
        $error = ['status' => 400, 'message' => 'Please check the given inputes'];
38
        abort($error['status'], $error['message']);
39
    }
40
41
    public function cannotCreateSetting()
42
    {
43
        $error = ['status' => 400, 'message' => 'Can\'t create setting'];
44
        abort($error['status'], $error['message']);
45
    }
46
47
    public function cannotUpdateSettingKey()
48
    {
49
        $error = ['status' => 400, 'message' => 'Can\'t update setting key'];
50
        abort($error['status'], $error['message']);
51
    }
52
53
    public function userIsBlocked()
54
    {
55
        $error = ['status' => 403, 'message' => 'You have been blocked'];
56
        abort($error['status'], $error['message']);
57
    }
58
59
    public function invalidResetToken()
60
    {
61
        $error = ['status' => 400, 'message' => 'Reset password token is invalid'];
62
        abort($error['status'], $error['message']);
63
    }
64
65
    public function invalidResetPassword()
66
    {
67
        $error = ['status' => 400, 'message' => 'Reset password is invalid'];
68
        abort($error['status'], $error['message']);
69
    }
70
71
    public function notFound($text)
72
    {
73
        $error = ['status' => 404, 'message' => 'The requested ' . $text . ' not found'];
74
        abort($error['status'], $error['message']);
75
    }
76
77
    public function generalError()
78
    {
79
        $error = ['status' => 404, 'message' => 'Something went wrong'];
80
        abort($error['status'], $error['message']);
81
    }
82
}