Controller   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 59
loc 59
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllSettings() 6 6 1
A createSetting() 6 6 1
A updateSetting() 6 6 1
A deleteSetting() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Containers\Settings\UI\API\Controllers;
4
5
use Apiato\Core\Foundation\Facades\Apiato;
6
use App\Containers\Settings\UI\API\Requests\CreateSettingRequest;
7
use App\Containers\Settings\UI\API\Requests\DeleteSettingRequest;
8
use App\Containers\Settings\UI\API\Requests\GetAllSettingsRequest;
9
use App\Containers\Settings\UI\API\Requests\UpdateSettingRequest;
10
use App\Containers\Settings\UI\API\Transformers\SettingTransformer;
11
use App\Ship\Parents\Controllers\ApiController;
12
use App\Ship\Transporters\DataTransporter;
13
14
/**
15
 * Class Controller
16
 *
17
 * @author  Mahmoud Zalt  <[email protected]>
18
 */
19 View Code Duplication
class Controller extends ApiController
0 ignored issues
show
Duplication introduced by Johannes Schobel
This class 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...
20
{
21
22
    /**
23
     * Get All application settings
24
     *
25
     * @param GetAllSettingsRequest $request
26
     *
27
     * @return mixed
28
     */
29
    public function getAllSettings(GetAllSettingsRequest $request)
0 ignored issues
show
Unused Code introduced by Mustafa Elkhalifa
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31
        $settings = Apiato::call('[email protected]');
32
33
        return $this->transform($settings, SettingTransformer::class);
34
    }
35
36
    /**
37
     * create a new setting
38
     *
39
     * @param CreateSettingRequest $request
40
     *
41
     * @return mixed
42
     */
43
    public function createSetting(CreateSettingRequest $request)
44
    {
45
        $setting = Apiato::call('[email protected]', [new DataTransporter($request)]);
46
47
        return $this->transform($setting, SettingTransformer::class);
48
    }
49
50
    /**
51
     * Updates an existing setting
52
     *
53
     * @param UpdateSettingRequest $request
54
     *
55
     * @return mixed
56
     */
57
    public function updateSetting(UpdateSettingRequest $request)
58
    {
59
        $setting = Apiato::call('[email protected]', [new DataTransporter($request)]);
60
61
        return $this->transform($setting, SettingTransformer::class);
62
    }
63
64
    /**
65
     * Removes a setting
66
     *
67
     * @param DeleteSettingRequest $request
68
     *
69
     * @return \Illuminate\Http\JsonResponse
70
     */
71
    public function deleteSetting(DeleteSettingRequest $request)
72
    {
73
        Apiato::call('[email protected]', [new DataTransporter($request)]);
74
75
        return $this->noContent();
76
    }
77
}
78