Completed
Push — master ( 78d4e7...979ecb )
by smiley
02:57
created

UploadedFileFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A createUploadedFile() 0 3 1
1
<?php
2
/**
3
 * Class UploadedFileFactory
4
 *
5
 * @filesource   UploadedFileFactory.php
6
 * @created      27.08.2018
7
 * @package      chillerlan\HTTP\Psr17
8
 * @author       smiley <[email protected]>
9
 * @copyright    2018 smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\HTTP\Psr17;
14
15
use chillerlan\HTTP\Psr7\UploadedFile;
16
use Psr\Http\Message\{StreamInterface, UploadedFileFactoryInterface, UploadedFileInterface};
17
18
final class UploadedFileFactory implements UploadedFileFactoryInterface{
19
20
	/**
21
	 * Create a new uploaded file.
22
	 *
23
	 * If a size is not provided it will be determined by checking the size of
24
	 * the file.
25
	 *
26
	 * @see http://php.net/manual/features.file-upload.post-method.php
27
	 * @see http://php.net/manual/features.file-upload.errors.php
28
	 *
29
	 * @param StreamInterface $stream          Underlying stream representing the
0 ignored issues
show
Documentation introduced by
Should the type for parameter $stream not be \Psr\Http\Message\StreamInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
30
	 *                                         uploaded file content.
31
	 * @param int             $size            in bytes
0 ignored issues
show
Documentation introduced by
Should the type for parameter $size not be null|integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
32
	 * @param int             $error           PHP file upload error
33
	 * @param string          $clientFilename  Filename as provided by the client, if any.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $clientFilename not be null|string?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
34
	 * @param string          $clientMediaType Media type as provided by the client, if any.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $clientMediaType not be null|string?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
35
	 *
36
	 *
37
	 * @return \Psr\Http\Message\UploadedFileInterface|\chillerlan\HTTP\Psr7\UploadedFile
38
	 *
39
	 * @throws \InvalidArgumentException If the file resource is not readable.
40
	 */
41
	public function createUploadedFile(StreamInterface $stream, int $size = null, int $error = \UPLOAD_ERR_OK, string $clientFilename = null, string $clientMediaType = null):UploadedFileInterface{
42
		return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
43
	}
44
45
}
46