Code Duplication    Length = 45-46 lines in 4 locations

app/Ship/Exceptions/Formatters/AuthenticationExceptionFormatter.php 1 location

@@ 15-60 (lines=46) @@
12
 * @author Johannes Schobel <[email protected]>
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class AuthenticationExceptionFormatter extends CoreExceptionsFormatter
16
{
17
18
    /**
19
     * Status Code.
20
     *
21
     * @var  integer
22
     */
23
    CONST STATUS_CODE = 401;
24
25
    /**
26
     * @param \Exception                    $exception
27
     * @param \Illuminate\Http\JsonResponse $response
28
     *
29
     * @return  array
30
     */
31
    public function responseData(Exception $exception, JsonResponse $response)
32
    {
33
        return [
34
            'code'    => $exception->getCode(),
35
            'message' => $exception->getMessage(),
36
            'errors'      => 'Missing or invalid Access Token!',
37
            'status_code' => self::STATUS_CODE,
38
        ];
39
    }
40
41
    /**
42
     * @param \Exception                    $exception
43
     * @param \Illuminate\Http\JsonResponse $response
44
     *
45
     * @return  mixed
46
     */
47
    function modifyResponse(Exception $exception, JsonResponse $response)
48
    {
49
        return $response;
50
    }
51
52
    /**
53
     * @return  int
54
     */
55
    public function statusCode()
56
    {
57
        return self::STATUS_CODE;
58
    }
59
60
}
61

app/Ship/Exceptions/Formatters/AuthorizationExceptionFormatter.php 1 location

@@ 15-60 (lines=46) @@
12
 * @author Johannes Schobel <[email protected]>
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class AuthorizationExceptionFormatter extends CoreExceptionsFormatter
16
{
17
18
    /**
19
     * Status Code.
20
     *
21
     * @var  integer
22
     */
23
    CONST STATUS_CODE = 403;
24
25
    /**
26
     * @param \Exception                    $exception
27
     * @param \Illuminate\Http\JsonResponse $response
28
     *
29
     * @return  array
30
     */
31
    public function responseData(Exception $exception, JsonResponse $response)
32
    {
33
        return [
34
            'code'    => $exception->getCode(),
35
            'message' => $exception->getMessage(),
36
            'errors'      => 'You have no access to this resource!',
37
            'status_code' => self::STATUS_CODE,
38
        ];
39
    }
40
41
    /**
42
     * @param \Exception                    $exception
43
     * @param \Illuminate\Http\JsonResponse $response
44
     *
45
     * @return  mixed
46
     */
47
    function modifyResponse(Exception $exception, JsonResponse $response)
48
    {
49
        return $response;
50
    }
51
52
    /**
53
     * @return  int
54
     */
55
    public function statusCode()
56
    {
57
        return self::STATUS_CODE;
58
    }
59
60
}
61

app/Ship/Exceptions/Formatters/MethodNotAllowedExceptionFormatter.php 1 location

@@ 15-60 (lines=46) @@
12
 * @author Johannes Schobel <[email protected]>
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class MethodNotAllowedExceptionFormatter extends CoreExceptionsFormatter
16
{
17
18
    /**
19
     * Status Code.
20
     *
21
     * @var  integer
22
     */
23
    CONST STATUS_CODE = 405;
24
25
    /**
26
     * @param \Exception                    $exception
27
     * @param \Illuminate\Http\JsonResponse $response
28
     *
29
     * @return  array
30
     */
31
    public function responseData(Exception $exception, JsonResponse $response)
32
    {
33
        return [
34
            'code'    => $exception->getCode(),
35
            'message' => $exception->getMessage(),
36
            'errors'      => 'Method Not Allowed!',
37
            'status_code' => self::STATUS_CODE,
38
        ];
39
    }
40
41
    /**
42
     * @param \Exception                    $exception
43
     * @param \Illuminate\Http\JsonResponse $response
44
     *
45
     * @return  mixed
46
     */
47
    function modifyResponse(Exception $exception, JsonResponse $response)
48
    {
49
        return $response;
50
    }
51
52
    /**
53
     * @return  int
54
     */
55
    public function statusCode()
56
    {
57
        return self::STATUS_CODE;
58
    }
59
60
}
61

app/Ship/Exceptions/Formatters/ValidationExceptionFormatter.php 1 location

@@ 15-59 (lines=45) @@
12
 * @author Johannes Schobel <[email protected]>
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class ValidationExceptionFormatter extends CoreExceptionsFormatter
16
{
17
18
    /**
19
     * Status Code.
20
     *
21
     * @var  integer
22
     */
23
    CONST STATUS_CODE = 422;
24
25
    /**
26
     * @param \Exception                    $exception
27
     * @param \Illuminate\Http\JsonResponse $response
28
     *
29
     * @return  array
30
     */
31
    public function responseData(Exception $exception, JsonResponse $response)
32
    {
33
        return [
34
            'code'    => $exception->getCode(),
35
            'message' => $exception->getMessage(),
36
            'errors'      => $exception->errors(),
37
            'status_code' => self::STATUS_CODE,
38
        ];
39
    }
40
41
    /**
42
     * @param \Exception                    $exception
43
     * @param \Illuminate\Http\JsonResponse $response
44
     *
45
     * @return  mixed
46
     */
47
    function modifyResponse(Exception $exception, JsonResponse $response)
48
    {
49
        return $response;
50
    }
51
52
    /**
53
     * @return  int
54
     */
55
    public function statusCode()
56
    {
57
        return self::STATUS_CODE;
58
    }
59
}
60