LogEvent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A registerScheduleLogger() 0 10 1
1
<?php
2
3
namespace PendoNL\LaravelScheduleLogger\Console\Scheduling;
4
5
use Illuminate\Console\Scheduling\Event;
6
use Illuminate\Console\Scheduling\Mutex;
7
8
class LogEvent extends Event
9
{
10
    /**
11
     * Create a new event instance.
12
     *
13
     * @param string $command
14
     * @param string $rawCommand
15
     */
16
    public function __construct(Mutex $mutex, $command, $rawCommand)
17
    {
18
        parent::__construct($mutex, $command);
19
20
        $this->mutex = $mutex;
21
        $this->command = $command;
22
        $this->output = $this->getDefaultOutput();
23
24
        $this->registerScheduleLogger($rawCommand);
25
    }
26
27
    /**
28
     * Add the logger functions to the before and
29
     * after calls of the event.
30
     */
31
    public function registerScheduleLogger($command)
32
    {
33
        $this->before(function () use ($command) {
34
            app()->make('laravel-schedulelogger')->start($command);
35
        });
36
37
        $this->after(function () use ($command) {
38
            app()->make('laravel-schedulelogger')->end($command);
39
        });
40
    }
41
}
42