<commit_before><?php

namespace Salexandru\Api\Middleware;

use Psr\Log\LoggerInterface as Logger;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

class RequestLoggingMiddleware
{

    private $logger;

    public function __construct(Logger $logger)
    {
        $this->logger = $logger;
    }

    public function __invoke(Request $req, Response $res, callable $next)
    {
        $context = [];
        $serverParams = $req->getServerParams();
        $mediaType = $this->extractMediaTypeFrom($req);
        $httpMethod = $req->getMethod();

        $message = 'Received {http_method} request to {url} from IP {ip}';
        if ($httpMethod === 'POST' || $httpMethod === 'PUT') {
            $message .= ' with body {body}';
            switch ($mediaType) {
                case 'application/json':
                case 'text/plain':
                case 'text/html':
                    $body = "{$req->getBody()}";
                    break;
                default:
                    $body = "(not shown)";
                    break;
            }
            $context['body'] = $body;
        }
        <commit_msg>Added some whitespace<commit_after><?php

namespace Salexandru\Api\Middleware;

use Psr\Log\LoggerInterface as Logger;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

class RequestLoggingMiddleware
{

    private $logger;

    public function __construct(Logger $logger)
    {
        $this->logger = $logger;
    }

    public function __invoke(Request $req, Response $res, callable $next)
    {
        $context = [];
        $serverParams = $req->getServerParams();
        $mediaType = $this->extractMediaTypeFrom($req);
        $httpMethod = $req->getMethod();

        $message = 'Received {http_method} request to {url} from IP {ip}';
        if ($httpMethod === 'POST' || $httpMethod === 'PUT') {
            $message .= ' with body {body}';
            switch ($mediaType) {
                case 'application/json':
                case 'text/plain':
                case 'text/html':
                    $body = "{$req->getBody()}";
                    break;
                default:
                    $body = "(not shown)";
                    break;
            }
            $context['body'] = $body;
        }

{'fraction_non_alphanumeric': 0.13047138047138046, 'fraction_numerical': 0.0, 'mean_word_length': 1.895249695493301, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7657694', 'n_tokens_mistral': 657, 'n_tokens_neox': 640, 'n_words': 154}