Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Spatie\FlareClient\FlareMiddleware;
4
 
5
use Spatie\FlareClient\Report;
6
 
7
class CensorRequestBodyFields implements FlareMiddleware
8
{
9
    protected array $fieldNames = [];
10
 
11
    public function __construct(array $fieldNames)
12
    {
13
        $this->fieldNames = $fieldNames;
14
    }
15
 
16
    public function handle(Report $report, $next)
17
    {
18
        $context = $report->allContext();
19
 
20
        foreach ($this->fieldNames as $fieldName) {
21
            if (isset($context['request_data']['body'][$fieldName])) {
22
                $context['request_data']['body'][$fieldName] = '<CENSORED>';
23
            }
24
        }
25
 
26
        $report->userProvidedContext($context);
27
 
28
        return $next($report);
29
    }
30
}