summaryrefslogtreecommitdiff
path: root/src/Support/Logger.php
blob: fb8616669028535344d57386ba1ed7f770d284de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace App\Support;

use Symfony\Component\HttpFoundation\Request;

class Logger
{
  public static function logRequestToFile(Request $request): void
  {
    $basePath = dirname(dirname(__DIR__)) . "/.phpunit.cache/" . str_replace("/", "_", $request->getPathInfo());

    file_put_contents(
      $basePath . "-body.json",
      $request->getContent()
    );

    file_put_contents(
      $basePath . "-header.json",
      json_encode($request->headers->all())
    );
  }
}