File   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
eloc 16
c 2
b 0
f 1
dl 0
loc 89
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getException() 0 3 1
A __construct() 0 8 1
A getName() 0 3 1
A isUploaded() 0 3 1
A getUploadedFile() 0 3 1
A getDetails() 0 3 1
1
<?php
2
3
namespace Slince\Upload;
4
5
use Exception;
6
use Symfony\Component\HttpFoundation\File\UploadedFile;
7
8
final class File
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $name;
14
15
    /**
16
     * @var UploadedFile
17
     */
18
    protected $uploadedFile;
19
20
    /**
21
     * Is uploaded
22
     *
23
     * @var boolean
24
     */
25
    protected $uploaded;
26
27
    /**
28
     * @var Exception
29
     */
30
    protected $exception;
31
32
    /**
33
     * Storage system returned.
34
     *
35
     * @var \Symfony\Component\HttpFoundation\File\File|mixed
36
     */
37
    protected $details;
38
39
    public function __construct(
40
        UploadedFile $uploadedFile, string $name, bool $uploaded, $details = null, $exception = null)
41
    {
42
        $this->uploadedFile = $uploadedFile;
43
        $this->name = $name;
44
        $this->uploaded = $uploaded;
45
        $this->details = $details;
46
        $this->exception = $exception;
47
    }
48
49
    /**
50
     * Gets the key generated by `Namer`
51
     *
52
     * @return string
53
     */
54
    public function getName(): string
55
    {
56
        return $this->name;
57
    }
58
59
    /**
60
     * Access file details saved in client by this object.
61
     *
62
     * @return UploadedFile
63
     */
64
    public function getUploadedFile(): UploadedFile
65
    {
66
        return $this->uploadedFile;
67
    }
68
69
    /**
70
     * Checks whether the file is uploaded successfully.
71
     *
72
     * @return bool
73
     */
74
    public function isUploaded(): bool
75
    {
76
        return $this->uploaded;
77
    }
78
79
    /**
80
     * The exception if the file is uploaded error.
81
     *
82
     * @return Exception
83
     */
84
    public function getException(): ?Exception
85
    {
86
        return $this->exception;
87
    }
88
89
    /**
90
     * File details provided by storage layer.
91
     *
92
     * @return \Symfony\Component\HttpFoundation\File\File|mixed
93
     */
94
    public function getDetails()
95
    {
96
        return $this->details;
97
    }
98
}
99