Completed
Push — master ( 2b8aa3...9a2a4c )
by David
06:24
created

RequestSeekableBodyPlugin::handleRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Http\Client\Common\Plugin;
6
7
use Http\Message\Stream\BufferedStream;
8
use Http\Promise\Promise;
9
use Psr\Http\Message\RequestInterface;
10
11
/**
12
 * Allow body used in request to be always seekable.
13
 *
14
 * @author Joel Wurtz <[email protected]>
15
 */
16 View Code Duplication
final class RequestSeekableBodyPlugin extends SeekableBodyPlugin
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21 2
    public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
22
    {
23 2
        if (!$request->getBody()->isSeekable()) {
24 1
            $request = $request->withBody(new BufferedStream($request->getBody(), $this->useFileBuffer, $this->memoryBufferSize));
25
        }
26
27 2
        return $next($request);
28
    }
29
}
30