Skip to content

Commit 5a8f7e5

Browse files
committed
Fix code style
1 parent 4f5675c commit 5a8f7e5

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

src/MultipartStreamBuilder.php

+13-21
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class MultipartStreamBuilder
4040

4141
/**
4242
* @var int Bytes of unallocated memory to use for stream buffer.
43-
* To have MultipartStreamBuilder manage it automatically, set to -1.
44-
* Default: -1
43+
* To have MultipartStreamBuilder manage it automatically, set to -1.
44+
* Default: -1
4545
*/
4646
private $bufferMaxMemory = -1;
4747

@@ -80,12 +80,10 @@ public function __construct($streamFactory = null)
8080
}
8181

8282
/**
83-
* Add a resource to the Multipart Stream
83+
* Add a resource to the Multipart Stream.
8484
*
85-
* @param string|resource|\Psr\Http\Message\StreamInterface $resource
86-
* The filepath, resource or StreamInterface of the data.
87-
* @param array $headers
88-
* Additional headers array: ['header-name' => 'header-value'].
85+
* @param string|resource|\Psr\Http\Message\StreamInterface $resource The filepath, resource or StreamInterface of the data.
86+
* @param array $headers Additional headers array: ['header-name' => 'header-value'].
8987
*
9088
* @return MultipartStreamBuilder
9189
*/
@@ -151,7 +149,7 @@ public function build()
151149
// Open a temporary read-write stream as buffer.
152150
// If the size is less than predefined limit, things will stay in memory.
153151
// If the size is more than that, things will be stored in temp file.
154-
$buffer = fopen('php://temp/maxmemory:' . $maxmemory, 'r+');
152+
$buffer = fopen('php://temp/maxmemory:'.$maxmemory, 'r+');
155153
foreach ($this->data as $data) {
156154
// Add start and headers
157155
fwrite($buffer, "--{$this->getBoundary()}\r\n".
@@ -379,11 +377,8 @@ private function createStream($resource)
379377
* in memory if the size of the stream is smaller than this size.
380378
* Otherwise, PHP will store the stream data in a temporary file.
381379
*
382-
* @param integer $size
383-
* Size of stream data buffered (in bytes) until using temporary
384-
* file to buffer.
385-
*
386-
* @return MultipartStreamBuilder
380+
* @param int $size Size of stream data buffered (in bytes)
381+
* until using temporary file to buffer.
387382
*/
388383
public function setBufferMaxMemory(int $size): MultipartStreamBuilder
389384
{
@@ -395,26 +390,23 @@ public function setBufferMaxMemory(int $size): MultipartStreamBuilder
395390
/**
396391
* Get and parse memory_limit into bytes integer.
397392
*
398-
* @return integer
399-
*
400-
* @throws \Exception
401-
* If the ini format does not match expectation.
393+
* @throws \Exception If the ini format does not match expectation.
402394
*/
403395
protected static function getAvailableMemory(): int
404396
{
405397
$memory_limit = ini_get('memory_limit');
406-
if ($memory_limit === '-1') {
398+
if ('-1' === $memory_limit) {
407399
// If there is no memory limit, return 100MB by default.
408400
return 100 * 1024 * 1024;
409401
}
410402
if (!preg_match('/^(\d+)(G|M|K|)$/', $memory_limit, $matches)) {
411403
throw new \Exception("Unknown memory_limit format: {$memory_limit}");
412404
}
413-
if ($matches[2] == 'G') {
405+
if ('G' === $matches[2]) {
414406
$memory_limit = $matches[1] * 1024 * 1024 * 1024; // nnnG -> nnn GB
415-
} else if ($matches[2] == 'M') {
407+
} elseif ('M' === $matches[2]) {
416408
$memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
417-
} else if ($matches[2] == 'K') {
409+
} elseif ('K' === $matches[2]) {
418410
$memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
419411
}
420412
return (int) $memory_limit - \memory_get_usage();

0 commit comments

Comments
 (0)