UploadedFileFactory::createUploadedFile()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 5
dl 0
loc 9
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace HttpSoft\Message;
6
7
use Psr\Http\Message\StreamInterface;
8
use Psr\Http\Message\UploadedFileFactoryInterface;
9
use Psr\Http\Message\UploadedFileInterface;
10
11
use const UPLOAD_ERR_OK;
12
13
final class UploadedFileFactory implements UploadedFileFactoryInterface
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18 2
    public function createUploadedFile(
19
        StreamInterface $stream,
20
        ?int $size = null,
21
        int $error = UPLOAD_ERR_OK,
22
        ?string $clientFilename = null,
23
        ?string $clientMediaType = null
24
    ): UploadedFileInterface {
25 2
        $size = (int) ($size === null ? $stream->getSize() : $size);
26 2
        return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
27
    }
28
}
29