CreateFieldCommandHandler::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\FieldGenerator\Handler;
4
5
use Hechoenlaravel\JarvisFoundation\FieldGenerator\FieldModel;
6
use Hechoenlaravel\JarvisFoundation\EntityGenerator\EntityModel;
7
use Hechoenlaravel\JarvisFoundation\FieldGenerator\Events\FieldWasCreated;
8
9
/**
10
 * Class FieldGeneratorHandler
11
 * @package Hechoenlaravel\JarvisFoundation\FieldGenerator\Handler
12
 */
13
class CreateFieldCommandHandler
14
{
15
    /**
16
     * Handle the creation of the Field in the Database
17
     * @param $command
18
     * @return static
19
     */
20
    public function handle($command)
21
    {
22
        $command->namespace = EntityModel::find($command->entity_id)->namespace;
23
        $field = FieldModel::create((array) $command);
24
        event(new FieldWasCreated($field));
25
        return $field;
26
    }
27
}
28