CreateEntryCommandHandler   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 1
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Entries\Handler;
4
5
use DB;
6
use Carbon\Carbon;
7
use Hechoenlaravel\JarvisFoundation\Entries\Events\EntryWasInserted;
8
9
/**
10
 * Class CreateEntryCommandHandler
11
 * @package Hechoenlaravel\JarvisFoundation\Entries\Handler
12
 */
13
class CreateEntryCommandHandler
14
{
15
    /**
16
     * Insert the record in the DB
17
     * @param $command
18
     */
19
    public function handle($command)
20
    {
21
        $command->input['created_at'] = Carbon::now();
22
        $command->input['updated_at'] = Carbon::now();
23
        $entry = DB::table($command->entity->getTableName())->insertGetId($command->input);
24
        event(new EntryWasInserted($command->entity, $entry, $command->input));
25
        return [
26
            'entry_id' => $entry,
27
            'input' => $command->input
28
        ];
29
    }
30
}
31