Passed
Push — master ( 9ffd86...045e57 )
by Anton
04:30
created

UploadedFileFactory::createUploadedFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 5
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);
34
    }
35
}