Completed
Push — master ( 3f2c58...3eb51e )
by wen
02:00
created

EventHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A info() 0 11 1
1
<?php
2
3
4
namespace Sco\ActionLog\Handlers;
5
6
use Auth;
7
use Illuminate\Database\Eloquent\Model;
8
use Sco\ActionLog\Events\AbstractEvent;
9
use Sco\ActionLog\LogInfo;
10
11
class EventHandler extends AbstractHandler
12
{
13
    private $event;
14
    private $model;
15
16
    public function __construct(AbstractEvent $event, Model $model)
17
    {
18
        $this->event = $event;
19
        $this->model = $model;
20
    }
21
22
    public function info()
23
    {
24
        return new LogInfo([
25
            'type'       => $this->event->type,
26
            'table_name' => $this->model->getTable(),
27
            'content'    => $this->event->getContent(),
28
            'client_ip'  => request()->getClientIp(),
29
            'client'     => $this->getClient(),
30
            'user_id'    => intval(Auth::id()),
31
        ]);
32
    }
33
}
34