FilterFieldFromInput   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 3
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Entries\Middleware;
4
5
use League\Tactician\Middleware;
6
7
class FilterFieldFromInput 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
        $fields = $command->entity->fields->pluck('slug', 'slug')->toArray();
18
        foreach ($command->input as $key => $input) {
19
            if (!isset($fields[$key])) {
20
                unset($command->input[$key]);
21
            }
22
        }
23
        return $next($command);
24
    }
25
}
26