CallPreAssignEventOnField::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\FieldGenerator\Middleware;
4
5
use League\Tactician\Middleware;
6
7
class CallPreAssignEventOnField implements Middleware
8
{
9
    /**
10
     * @param object $command
11
     * @param callable $next
12
     *
13
     * @return mixed
14
     */
15
    public function execute($command, callable $next)
16
    {
17
        $fieldType = $this->setFieldType($command->type);
18
        $fieldType->preAssignEvent($command);
19
        return $next($command);
20
    }
21
22
    /**
23
     * @param $type
24
     * @return \Illuminate\Foundation\Application|mixed
25
     * @throws \NotAcceptableHttpException
26
     */
27
    private function setFieldType($type)
28
    {
29
        $fieldTypes = app('field.types');
30
        return $fieldTypes->getFieldClass($type);
31
    }
32
}
33