StoreRuang   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 47
loc 47
rs 10
wmc 4
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 4 4 1
A rules() 8 8 1
A messages() 20 20 2

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 Bantenprov\YankesInfoKamar\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7 View Code Duplication
class StoreRuang extends FormRequest
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...
8
{
9
    /**
10
    * Determine if the user is authorized to make this request.
11
    *
12
    * @return bool
13
    */
14
    public function authorize()
15
    {
16
        return true;
17
    }
18
19
    /**
20
    * Get the validation rules that apply to the request.
21
    *
22
    * @return array
23
    */
24
    public function rules()
25
    {
26
        return [
27
            'kode_ruang' => 'required',
28
            'nama_ruang' => 'required',
29
            'kelas_id' => 'required',
30
        ];
31
    }
32
33
    public function messages()
34
    {
35
        $messages = [
36
            'kelas_id.required' => 'Kelas Rawah Inap belum di pilih',
37
            'kode_ruang.required' => 'Kode ruang Rawat Inap Masih Kosong',
38
            'nama_ruang.required' => 'Nama ruang Rawat Inap Tidak Boleh Kosong'
39
        ];
40
41
        if ('PATCH' === $this->method()){
42
43
            $messages = [
44
                'kelas_id.required' => 'Kelas Rawah Inap belum di pilih',
45
                'kode_ruang.required' => 'Kode ruang Rawat Inap tidak boleh kosong',
46
                'nama_ruang.required' => 'Nama ruang Rawat Inap Tidak Boleh Kosong'
47
            ];
48
49
        }
50
51
        return $messages;
52
    }
53
}
54