Completed
Push — master ( c8ea4b...c4213a )
by Sherif
02:51
created

ErrorHandler   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 9
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 47
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A unAuthorized() 0 4 1
A tokenExpired() 0 4 1
A noPermissions() 0 4 1
A loginFailed() 0 4 1
A redisNotRunning() 0 4 1
A dbQueryError() 0 4 1
A cannotCreateSetting() 0 4 1
A cannotUpdateSettingKey() 0 4 1
A notFound() 0 4 1
1
<?php namespace App\Modules\Core;
2
3
class ErrorHandler
4
{
5
    public function unAuthorized()
6
    {
7
        return ['status' => 401, 'message' => 'Please login before any action'];
8
    }
9
10
    public function tokenExpired()
11
    {
12
        return ['status' => 401, 'message' => 'Login token expired'];
13
    }
14
15
     public function noPermissions()
16
    {
17
        return ['status' => 401, 'message' => 'No permissions'];
18
    }
19
20
    public function loginFailed()
21
    {
22
        return ['status' => 400, 'message' => 'Wrong mail or password'];
23
    }
24
25
    public function redisNotRunning()
26
    {
27
        return ['status' => 400, 'message' => 'Your redis notification server isn\'t running'];
28
    }
29
30
    public function dbQueryError()
31
    {
32
        return ['status' => 400, 'message' => 'Please check the given inputes'];
33
    }
34
35
    public function cannotCreateSetting()
36
    {
37
        return ['status' => 400, 'message' => 'Can\'t create setting'];
38
    }
39
40
    public function cannotUpdateSettingKey()
41
    {
42
        return ['status' => 400, 'message' => 'Can\'t update setting key'];
43
    }
44
45
    public function notFound($text)
46
    {
47
        return ['status' => 404, 'message' => 'The requested ' . $text . ' not found'];
48
    }
49
}