PluginProbe
DecaLog / 4.4.0
DecaLog v4.4.0
3.0.2 3.1.0 3.10.0 3.2.0 3.3.0 3.4.0 3.4.1 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.6.3 3.7.0 3.7.1 3.8.0 3.9.0 3.9.1 4.0.0 4.1.0 4.2.0 4.3.0 4.3.1 4.4.0 4.5.0 All 75 releases
decalog / includes / libraries / http / client-common / Plugin / SeekableBodyPlugin.php

SeekableBodyPlugin.php in DecaLog 4.4.0, at includes/libraries/http/client-common/Plugin/SeekableBodyPlugin.php

48 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 /**
16 * @var bool
17 */
18 protected $useFileBuffer;
19
20 /**
21 * @var int
22 */
23 protected $memoryBufferSize;
24
25 /**
26 * @param array{'use_file_buffer'?: bool, 'memory_boffer_size'?: int} $config
27 *
28 * Configuration options:
29 * - use_file_buffer: Whether this plugin should use a file as a buffer if the stream is too big, defaults to true
30 * - memory_buffer_size: Max memory size in bytes to use for the buffer before it use a file, defaults to 2097152 (2 mb)
31 */
32 public function __construct(array $config = [])
33 {
34 $resolver = new OptionsResolver();
35 $resolver->setDefaults([
36 'use_file_buffer' => true,
37 'memory_buffer_size' => 2097152,
38 ]);
39 $resolver->setAllowedTypes('use_file_buffer', 'bool');
40 $resolver->setAllowedTypes('memory_buffer_size', 'int');
41
42 $options = $resolver->resolve($config);
43
44 $this->useFileBuffer = $options['use_file_buffer'];
45 $this->memoryBufferSize = $options['memory_buffer_size'];
46 }
47 }
48