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

AbstractEvent   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getContent() 0 7 1
1
<?php
2
3
4
namespace Sco\ActionLog\Events;
5
6
use Illuminate\Database\Eloquent\Model;
7
use Sco\ActionLog\Handlers\EventHandler;
8
use Sco\ActionLog\Traits\HasAttributes;
9
10
abstract class AbstractEvent
11
{
12
    use HasAttributes;
13
14
    public $type;
15
16
    public $logInfo;
17
18
    public function __construct(Model $model)
19
    {
20
        $this->setAttribute([
21
            'model.original'   => $model->getOriginal(),
22
            'model.attributes' => $model->getAttributes(),
23
        ]);
24
25
        $handler = new EventHandler($this, $model);
26
27
        $this->logInfo = $handler->info();
28
    }
29
30
    public function getContent()
31
    {
32
        return [
33
            'from' => $this->getAttribute('model.original'),
34
            'to'   => $this->getAttribute('model.attributes'),
35
        ];
36
    }
37
38
39
}
40