Passed
Push — master ( 5679ef...aad9e9 )
by Kirill
04:11
created

UploadedFileFactory::createUploadedFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 2
nc 2
nop 5
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Auth\Diactoros;
13
14
use Psr\Http\Message\StreamInterface;
15
use Psr\Http\Message\UploadedFileFactoryInterface;
16
use Psr\Http\Message\UploadedFileInterface;
17
use Laminas\Diactoros\UploadedFile;
18
19
final class UploadedFileFactory implements UploadedFileFactoryInterface
20
{
21
    /**
22
     * @inheritdoc
23
     */
24
    public function createUploadedFile(
25
        StreamInterface $stream,
26
        int $size = null,
27
        int $error = \UPLOAD_ERR_OK,
28
        string $clientFilename = null,
29
        string $clientMediaType = null
30
    ): UploadedFileInterface {
31
        if ($size === null) {
32
            $size = $stream->getSize();
33
        }
34
35
        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 Laminas\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

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