Input   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 3
1
<?php
2
3
namespace Te7aHoudini\LaravelTrix\Pipes;
4
5
use Te7aHoudini\LaravelTrix\LaravelTrix;
6
7
class Input
8
{
9
    public function handle(LaravelTrix $trix, \Closure $next)
10
    {
11
        $html = is_object($trix->model) && $trix->model->exists ? htmlspecialchars(optional($trix->model->trixRichText()->where('field', $trix->config['field'])->first())->content, ENT_QUOTES) : '';
12
13
        $trix->html .= "<input id='{$trix->config['id']}' value='{$html}' name='{$trix->loweredModelName}-trixFields[{$trix->config['field']}]' type='hidden'>";
14
15
        return $next($trix);
16
    }
17
}
18