1 | <?php |
||
14 | class SaveResponse |
||
15 | { |
||
16 | use Utils\FileTrait; |
||
17 | |||
18 | /** |
||
19 | * Execute the middleware. |
||
20 | * |
||
21 | * @param RequestInterface $request |
||
22 | * @param ResponseInterface $response |
||
23 | * @param callable $next |
||
24 | * |
||
25 | * @return ResponseInterface |
||
26 | */ |
||
27 | public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next) |
||
44 | |||
45 | /** |
||
46 | * Check whether the response can be saved or not. |
||
47 | * |
||
48 | * @param RequestInterface $request |
||
49 | * @param ResponseInterface $response |
||
50 | * |
||
51 | * @return bool |
||
52 | */ |
||
53 | private function canSave(RequestInterface $request, ResponseInterface $response) |
||
75 | |||
76 | /** |
||
77 | * Write the stream to the given path. |
||
78 | * |
||
79 | * @param StreamInterface $stream |
||
80 | * @param string $path |
||
81 | */ |
||
82 | private static function writeStream(StreamInterface $stream, $path) |
||
104 | } |
||
105 |