UploaderException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
1
<?php
2
3
namespace Rostenkowski\Resize\Exceptions;
4
5
6
use RuntimeException;
7
8
/**
9
 * Image upload error exception
10
 */
11
class UploaderException extends RuntimeException
12
{
13
14
	/**
15
	 * Upload error code -> error message map
16
	 *
17
	 * @var string[]
18
	 */
19
	private $messages = [
20
		0 => "There is no error, the file uploaded with success",
21
		1 => "The uploaded file exceeds the upload_max_filesize directive in php.ini",
22
		2 => "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form",
23
		3 => "The uploaded file was only partially uploaded",
24
		4 => "No file was uploaded",
25
		6 => "Missing a temporary folder",
26
	];
27
28
29
	/**
30
	 * Constructs the upload error exception using the given upload error code.
31
	 *
32
	 * @param string $code
33
	 */
34
	public function __construct($code)
35
	{
36
		parent::__construct($this->messages[$code], $code);
0 ignored issues
show
Bug introduced by
$code of type string is incompatible with the type integer expected by parameter $code of RuntimeException::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
		parent::__construct($this->messages[$code], /** @scrutinizer ignore-type */ $code);
Loading history...
37
	}
38
39
40
}
41