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

SeekableBodyPlugin   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 51.72 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 15
loc 29
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 15 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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