• File: CensorRequestBodyFields.php
  • Full Path: /home/masbinta/public_html/core/vendor/facade/flare-client-php/src/Middleware/CensorRequestBodyFields.php
  • File size: 663 bytes
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace Facade\FlareClient\Middleware;

use Facade\FlareClient\Report;

class CensorRequestBodyFields
{
    protected $fieldNames = [];

    public function __construct(array $fieldNames)
    {
        $this->fieldNames = $fieldNames;
    }

    public function handle(Report $report, $next)
    {
        $context = $report->allContext();

        foreach ($this->fieldNames as $fieldName) {
            if (isset($context['request_data']['body'][$fieldName])) {
                $context['request_data']['body'][$fieldName] = '<CENSORED>';
            }
        }

        $report->userProvidedContext($context);

        return $next($report);
    }
}