Completed
Push — feature/backpack ( e25852...16fb41 )
by Chris
06:37
created

JobPosterCrudController::setup()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 65
Code Lines 49

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 49
dl 0
loc 65
ccs 0
cts 26
cp 0
rs 9.1127
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\Controllers\Admin;
4
5
use Backpack\CRUD\app\Http\Controllers\CrudController;
6
7
class JobPosterCrudController extends CrudController
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class JobPosterCrudController
Loading history...
8
{
9
    public function setup()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setup()
Loading history...
10
    {
11
        $this->crud->setModel("App\Models\JobPoster");
12
        $this->crud->setRoute("admin/job-poster");
13
        $this->crud->setEntityNameStrings('job poster', 'job posters');
14
15
        $this->crud->denyAccess('create');
16
        $this->crud->denyAccess('delete');
17
18
        if (!$this->request->has('order')) {
19
            $this->crud->orderBy('close_date_time', 'desc');
20
        }
21
22
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
23
            'name' => 'title',
24
            'type' => 'text',
25
            'label' => 'Title'
26
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
27
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
28
            'name' => 'open_date_time',
29
            'type' => 'datetime',
30
            'label' => 'Open Date'
31
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
32
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
33
            'name' => 'close_date_time',
34
            'type' => 'datetime',
35
            'label' => 'Close Date'
36
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
37
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
38
            'name' => "status",
39
            'label' => "Status",
40
            'type' => "model_function",
41
            'function_name' => 'status',
42
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
43
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
44
            'name' => "published",
45
            'label' => "Published",
46
            'type' => "check",
47
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
48
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
49
            'name' => 'manager.user.name',
50
            'type' => 'text',
51
            'label' => 'Manager'
52
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
53
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
54
            'name' => "submitted_applications_count",
55
            'label' => "Applications",
56
            'type' => "model_function",
57
            'function_name' => 'submitted_applications_count',
58
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
59
60
        $this->crud->addField([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
61
            'name' => 'title',
62
            'label' => "Title",
63
            'type' => 'text',
64
            'attributes' => [
65
                'readonly' => 'readonly'
66
            ]
67
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
68
        $this->crud->addField([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
69
            'name' => 'close_date_time',
70
            'label' => 'Close Date',
71
            'type' => 'datetime_picker',
72
            'datetime_picker_options' => [
73
                'format' => 'YYYY-MM-DD HH:mm:ss',
74
            ],
75
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
76
    }
77
78
    public function update($request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

78
    public function update(/** @scrutinizer ignore-unused */ $request)

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

Loading history...
Coding Style introduced by
Missing doc comment for function update()
Loading history...
79
    {
80
        $response = parent::updateCrud();
81
        return $response;
82
    }
83
}
84