Completed
Push — master ( b7a7bb...f6579a )
by Arman
36s queued 13s
created

FileUploadException::directoryNotWritable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.5.0
13
 */
14
15
namespace Quantum\Exceptions;
16
17
/**
18
 * Class FileUploadException
19
 * @package Quantum\Exceptions
20
 */
21
class FileUploadException extends \Exception
22
{
23
24
    /**
25
     * File was not sent with a POST request message
26
     */
27
    const FILE_NOT_UPLOADED = 'The uploaded file was not sent with a POST request';
28
29
    /**
30
     * Upload file not found message
31
     */
32
    const UPLOADED_FILE_NOT_FOUND = 'Cannot find uploaded file identified by key `{%1}`';
33
34
    /**
35
     * File type not allowed message
36
     */
37
    const FILE_TYPE_NOT_ALLOWED = 'The file type `{%1}` is not allowed';
38
39
    /**
40
     * @return \Quantum\Exceptions\FileUploadException
41
     */
42
    public static function fileNotUploaded(): FileUploadException
43
    {
44
        return new static(self::FILE_NOT_UPLOADED, E_WARNING);
45
    }
46
47
    /**
48
     * @param string $name
49
     * @return \Quantum\Exceptions\FileUploadException
50
     */
51
    public static function fileNotFound(string $name): FileUploadException
52
    {
53
        return new static(_message(self::UPLOADED_FILE_NOT_FOUND, $name), E_WARNING);
54
    }
55
56
    /**
57
     * @param string $name
58
     * @return \Quantum\Exceptions\FileUploadException
59
     */
60
    public static function fileTypeNotAllowed(string $name): FileUploadException
61
    {
62
        return new static(_message(self::FILE_TYPE_NOT_ALLOWED, $name), E_WARNING);
63
    }
64
65
}
66