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

SeekableBodyPlugin::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 10
cts 10
cp 1
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Http\Client\Common\Plugin;
6
7
use Http\Client\Common\Plugin;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
/**
11
 * @internal
12
 */
13
abstract class SeekableBodyPlugin implements Plugin
14
{
15
    protected $useFileBuffer;
16
17
    protected $memoryBufferSize;
18
19
    /**
20
     * @param array $config {
21
     *
22
     *    @var bool $use_file_buffer    Whether this plugin should use a file as a buffer if the stream is too big, defaults to true
23
     *    @var int  $memory_buffer_size Max memory size in bytes to use for the buffer before it use a file, defaults to 2097152 (2 mb)
24
     * }
25
     */
26 8 View Code Duplication
    public function __construct(array $config = [])
0 ignored issues
show
Duplication introduced by
This method 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...
27
    {
28 8
        $resolver = new OptionsResolver();
29 8
        $resolver->setDefaults([
30 8
            'use_file_buffer' => true,
31
            'memory_buffer_size' => 2097152,
32
        ]);
33 8
        $resolver->setAllowedTypes('use_file_buffer', 'bool');
34 8
        $resolver->setAllowedTypes('memory_buffer_size', 'int');
35
36 8
        $options = $resolver->resolve($config);
37
38 8
        $this->useFileBuffer = $options['use_file_buffer'];
39 8
        $this->memoryBufferSize = $options['memory_buffer_size'];
40 8
    }
41
}
42