UpdatePostRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 25.81 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 0
cbo 0
dl 8
loc 31
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 4 1
A translationRules() 0 9 1
A authorize() 0 4 1
A translationMessages() 8 8 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 namespace Modules\Blog\Http\Requests;
2
3
use Modules\Core\Internationalisation\BaseFormRequest;
4
5
class UpdatePostRequest extends BaseFormRequest
6
{
7
    public function rules()
8
    {
9
        return [];
10
    }
11
12
    public function translationRules()
13
    {
14
        $id = $this->route()->getParameter('post')->id;
15
16
        return [
17
            "title" => "required",
18
            "slug" => "required|unique:blog__post_translations,slug,$id,post_id,locale,$this->localeKey",
19
        ];
20
    }
21
22
    public function authorize()
23
    {
24
        return true;
25
    }
26
27 View Code Duplication
    public function translationMessages()
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...
28
    {
29
        return [
30
            'title.required' => trans('blog::messages.title is required'),
31
            'slug.required' => trans('blog::messages.slug is required'),
32
            'slug.unique' => trans('blog::messages.slug is unique'),
33
        ];
34
    }
35
}
36