Completed
Push — api/develop ( 20ea63...2875f0 )
by Bertrand
05:58
created

PayGradeRequest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 94.44%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 54
ccs 17
cts 18
cp 0.9444
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 12 2
B authorize() 0 24 5
1
<?php
2
3
/**
4
 * This file is part of the HRis Software package.
5
 *
6
 * HRis - Human Resource and Payroll System
7
 *
8
 * @link    http://github.com/HB-Co/HRis
9
 */
10
namespace HRis\Api\Requests\Admin\Job;
11
12
use HRis\Http\Requests\Request;
13
14
class PayGradeRequest extends Request
15
{
16
    /**
17
     * Get the validation rules that apply to the request.
18
     *
19
     * @return array
20
     *
21
     * @author Bertrand Kintanar <[email protected]>
22
     */
23 14
    public function rules()
24
    {
25 14
        if ($this->isMethod('post')) {
26
            return [
27 8
                'name'       => 'required|unique:pay_grades',
28 8
                'min_salary' => 'required',
29 8
                'max_salary' => 'required',
30 8
            ];
31
        }
32
33 10
        return [];
34
    }
35
36
    /**
37
     * Determine if the user is authorized to make this request.
38
     *
39
     * @return bool
40
     *
41
     * @author Bertrand Kintanar <[email protected]>
42
     */
43 14
    public function authorize()
44
    {
45 14
        $permission = 'admin.job.pay-grades';
46
47
        // Create
48 14
        if ($this->isMethod('post')) {
49 8
            return $this->logged_user->hasAccess($permission.'.create');
50
        } // Delete
51
        else {
52 10
            if ($this->isMethod('delete')) {
53 4
                return $this->logged_user->hasAccess($permission.'.delete');
54
            } // View
55
            else {
56 6
                if ($this->isMethod('get')) {
57 2
                    return $this->logged_user->hasAccess($permission.'.view');
58
                } // Update
59
                else {
60 4
                    if ($this->isMethod('patch')) {
61 4
                        return $this->logged_user->hasAccess($permission.'.update');
62
                    }
63
                }
64
            }
65
        }
66
    }
67
}
68