UploadedFileFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createUploadedFile() 0 15 3
1
<?php
2
declare(strict_types=1);
3
namespace Bnf\Typo3HttpFactory;
4
5
use Psr\Http\Message\StreamInterface;
6
use Psr\Http\Message\UploadedFileFactoryInterface;
7
use Psr\Http\Message\UploadedFileInterface;
8
use TYPO3\CMS\Core\Http\UploadedFile;
9
10
final class UploadedFileFactory implements UploadedFileFactoryInterface
11
{
12
    public function createUploadedFile(
13
        StreamInterface $stream,
14
        int $size = null,
15
        int $error = \UPLOAD_ERR_OK,
16
        string $clientFilename = null,
17
        string $clientMediaType = null
18
    ): UploadedFileInterface {
19
        if ($size === null) {
20
            $size = $stream->getSize();
21
            if ($size === null) {
22
                throw new \InvalidArgumentException('Stream size could not be determined.', 1566823423);
23
            }
24
        }
25
26
        return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
27
    }
28
}
29