Completed
Push — dev ( a25222...cc464e )
by Gray
05:55
created

JobPublished::handle()   A

Complexity

Conditions 6
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 10
ccs 0
cts 5
cp 0
rs 9.2222
c 0
b 0
f 0
cc 6
nc 2
nop 1
crap 42
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Listeners;
4
5
use App\Events\JobSaved;
6
use Illuminate\Queue\InteractsWithQueue;
7
use Illuminate\Contracts\Queue\ShouldQueue;
8
use Illuminate\Support\Facades\Log;
9
10
class JobPublished
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class JobPublished
Loading history...
11
{
12
    /**
13
     * Create the event listener.
14
     *
15
     * @return void
16
     */
17
    public function __construct()
18
    {
19
        //
20
    }
21
22
    /**
23
     * Handle the event.
24
     *
25
     * @param  JobSaved  $event
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...
26
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
27
     */
28
    public function handle(JobSaved $event)
29
    {
30
        $job = $event->job;
31
32
        //If job has just been created, log if its being published now
33
        //If job is being modified, only want to log when it goes from unpublished to published
34
        if ( ($job->wasRecentlyCreated && $job->published) ||
35
                (!$job->wasRecentlyCreated && $job->published && !$job->getOriginal('published'))) {
0 ignored issues
show
Coding Style introduced by
Multi-line IF statement not indented correctly; expected 12 spaces but found 16
Loading history...
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
36
37
            Log::notice('Job published: job {id='.$job->id."} published by manager {id=".$job->manager->id.", email=".$job->manager->user->email."}");
38
        }
39
    }
40
}
41