Completed
Push — master ( a2ea8b...2c4876 )
by Sherif
02:24
created

SettingsController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 30
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A saveMany() 4 4 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
namespace App\Modules\V1\Core\Http\Controllers;
3
4
use Illuminate\Foundation\Http\FormRequest;
5
use App\Modules\V1\Core\Http\Controllers\BaseApiController;
6
use Illuminate\Http\Request;
7
8
9 View Code Duplication
class SettingsController extends BaseApiController
0 ignored issues
show
Duplication introduced by
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...
10
{
11
    /**
12
     * The name of the model that is used by the base api controller 
13
     * to preform actions like (add, edit ... etc).
14
     * @var string
15
     */
16
    protected $model               = 'settings';
17
18
    /**
19
     * The validations rules used by the base api controller
20
     * to check before add.
21
     * @var array
22
     */
23
    protected $validationRules  = [
24
    'name'  => 'required|string|max:100',
25
    'value' => 'required|string'
26
    ];
27
    
28
    /**
29
     * Save list of settings.
30
     * 
31
     * @param  \Illuminate\Http\Request  $request
32
     * @return \Illuminate\Http\Response
33
     */
34
    public function saveMany(Request $request) 
35
    {   
36
        return \Response::json($this->repo->saveMany($request->all()), 200);
37
    }
38
}
39