Test Failed
Pull Request — master (#19)
by Flo
03:56
created

AbstractRestfulController::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Faulancer\Controller;
4
5
use Faulancer\Http\JsonResponse;
6
7
/**
8
 * Class RestfulAbstractController
9
 *
10
 * @category REST
11
 * @package  Faulancer\AbstractController
12
 * @author   Florian Knapp <[email protected]>
13
 * @license  MIT License
14
 * @link     Currently no information
15
 */
16
abstract class AbstractRestfulController extends AbstractController
17
{
18
19
    /**
20
     * GET
21
     *
22
     * @return void
23
     */
24
    public function get()
25
    {
26
    }
27
28
    /**
29
     * POST
30
     *
31
     * @return void
32
     */
33
    public function create()
34
    {
35
    }
36
37
    /**
38
     * UPDATE
39
     *
40
     * @return void
41
     */
42
    public function update()
43
    {
44
    }
45
46
    /**
47
     * DELETE
48
     *
49
     * @return void
50
     */
51
    public function delete()
52
    {
53
    }
54
55
    /**
56
     * Return success response
57
     *
58
     * @param array $data The response data
59
     *
60
     * @return JsonResponse
61
     */
62 View Code Duplication
    protected function success($data = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
    {
64
        $response = new JsonResponse();
65
66
        $response->setContent(
67
            [
68
                'success' => true,
69
                'data'    => $data,
70
                'errors'  => []
71
            ]
72
        );
73
74
        $response->setCode(200);
75
76
        return $response;
77
    }
78
79
    /**
80
     * Return erroneous response
81
     *
82
     * @param array $errors The response errors
83
     *
84
     * @return JsonResponse
85
     */
86 View Code Duplication
    protected function error($errors = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
87
    {
88
        $response = new JsonResponse();
89
90
        $response->setContent(
91
            [
92
                'success' => false,
93
                'data'    => [],
94
                'errors'  => $errors
95
            ]
96
        );
97
        $response->setCode(400);
98
99
        return $response;
100
    }
101
102
}