Passed
Pull Request — dev (#512)
by Tristan
13:09 queued 07:15
created

updateForApplication()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 33
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 33
ccs 0
cts 21
cp 0
rs 9.568
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 12
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\Controllers;
4
5
use App\Models\ApplicationReview;
6
use App\Models\JobApplication;
7
use App\Models\Lookup\ReviewStatus;
8
use App\Models\Lookup\ReviewDecision;
9
use Illuminate\Http\Request;
10
use Illuminate\Validation\Rule;
11
12
class ApplicationReviewController extends Controller
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ApplicationReviewController
Loading history...
13
{
14
    /**
15
     * Update the review for the specified application.
16
     *
17
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 2 found
Loading history...
18
     * @param  \App\Models\JobApplication  $application
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
19
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
20
     */
21
    public function updateForApplication(Request $request, JobApplication $application)
22
    {
23
        $request->validate([
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...
24
            'review_status' => [
25
                'required',
26
                Rule::in(ReviewStatus::all()->pluck('id')->toArray())
27
            ],
28
            'review_decision' => [
29
                'required',
30
                Rule::in(ReviewDecision::all()->pluck('id')->toArray())
31
            ],
32
            'reviewer' => 'required|string',
33
            'notes' => 'nullable|string'
34
        ]);
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...
35
36
        $review = $application->application_review;
37
        if ($review === null) {
38
            $review = new ApplicationReview();
39
            $review->job_application()->associate($application);
40
        }
41
        $review->fill([
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...
42
            'review_status_id' => $request->input('review_status'),
43
            'review_decision_id' => $request->input('review_decision'),
44
            'reviewer' => $request->input('reviewer'),
45
            'notes' => $request->input('notes'),
46
        ]);
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...
47
        $review->save();
48
49
        if($request->ajax()) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
50
            return $review->toJson();
1 ignored issue
show
Bug Best Practice introduced by
The expression return $review->toJson() returns the type string which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
51
        }
52
53
        return redirect()->back();
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->back() returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
54
    }
55
}
56