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

LogApplicationRetrieved   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 11
dl 0
loc 34
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 16 3
A __construct() 0 2 1
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\ApplicationRetrieved;
6
use Illuminate\Queue\InteractsWithQueue;
7
use Illuminate\Contracts\Queue\ShouldQueue;
8
use Illuminate\Support\Facades\Log;
9
use Illuminate\Support\Facades\Auth;
10
11
class LogApplicationRetrieved
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class LogApplicationRetrieved
Loading history...
12
{
13
    /**
14
     * Create the event listener.
15
     *
16
     * @return void
17
     */
18
    public function __construct()
19
    {
20
        //
21
    }
22
23
    /**
24
     * Handle the event.
25
     *
26
     * @param  AppliationRetrieved  $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...
27
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
28
     */
29
    public function handle(ApplicationRetrieved $event)
30
    {
31
        $application = $event->application;
32
33
        if (Auth::check()) {
34
            $user = Auth::user();
35
36
            //Don't bother logging when an applicant views their own application
37
            if ($application->applicant->user->id != $user->id) {
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
38
                $applicationText = "{id=".$application->id.", status=".$application->application_status->name."}";
39
                $userText = "{id=".$user->id.", email=".$user->email.", role=".$user->user_role->name."}";
0 ignored issues
show
Bug introduced by
Accessing email on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
Bug introduced by
Accessing user_role on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
40
                Log::notice("Application viewed: application ".$applicationText." viewed by user ".$userText);
41
            }
42
        } else {
43
            $applicationText = "{id=".$application->id.", status=".$application->application_status->name."}";
44
            Log::notice("Application retrieved: application ".$applicationText." retrieved with no user logged in");
45
        }
46
    }
47
}
48