Passed
Push — master ( 5e186e...dbb2e0 )
by Anton
02:56
created

UploadedFileFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createUploadedFile() 0 12 2
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
declare(strict_types=1);
9
10
namespace Spiral\Http\Diactoros;
11
12
use Psr\Http\Message\StreamInterface;
13
use Psr\Http\Message\UploadedFileFactoryInterface;
14
use Psr\Http\Message\UploadedFileInterface;
15
use Zend\Diactoros\UploadedFile;
16
17
final class UploadedFileFactory implements UploadedFileFactoryInterface
18
{
19
    /**
20
     * @inheritdoc
21
     */
22
    public function createUploadedFile(
23
        StreamInterface $stream,
24
        int $size = null,
25
        int $error = \UPLOAD_ERR_OK,
26
        string $clientFilename = null,
27
        string $clientMediaType = null
28
    ): UploadedFileInterface {
29
        if ($size === null) {
30
            $size = $stream->getSize();
31
        }
32
33
        return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
0 ignored issues
show
Bug introduced by
It seems like $size can also be of type null; however, parameter $size of Zend\Diactoros\UploadedFile::__construct() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        return new UploadedFile($stream, /** @scrutinizer ignore-type */ $size, $error, $clientFilename, $clientMediaType);
Loading history...
34
    }
35
}