Upload::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace WSW\SimpleUpload\Entities;
4
5
/**
6
 * Class File
7
 * @package WSW\SimpleUpload\Entities
8
 */
9
class Upload extends AbstractEntity
10
{
11
    /**
12
     * @var string
13
     */
14
    private $name;
15
16
    /**
17
     * @var string
18
     */
19
    private $type;
20
21
    /**
22
     * @var string
23
     */
24
    private $tmp_name;
25
26
    /**
27
     * @var int
28
     */
29
    private $error;
30
31
    /**
32
     * @var int
33
     */
34
    private $size;
35
36
    /**
37
     * @return string
38
     */
39 6
    public function getName()
40
    {
41 6
        return $this->name;
42
    }
43
44
    /**
45
     * @param string $name
46
     * @return self
47
     */
48 5
    public function setName($name)
49
    {
50 5
        $this->name = $name;
51 5
        return $this;
52
    }
53
54
    /**
55
     * @return string
56
     */
57 1
    public function getType()
58
    {
59 1
        return $this->type;
60
    }
61
62
    /**
63
     * @param string $type
64
     * @return self
65
     */
66 5
    public function setType($type)
67
    {
68 5
        $this->type = $type;
69 5
        return $this;
70
    }
71
72
    /**
73
     * @return string
74
     */
75 4
    public function getTmpName()
76
    {
77 4
        return $this->tmp_name;
78
    }
79
80
    /**
81
     * @param string $tmp_name
82
     * @return self
83
     */
84 5
    public function setTmpName($tmp_name)
85
    {
86 5
        $this->tmp_name = $tmp_name;
87 5
        return $this;
88
    }
89
90
    /**
91
     * @return int
92
     */
93 4
    public function getError()
94
    {
95 4
        return $this->error;
96
    }
97
98
    /**
99
     * @param int $error
100
     * @return self
101
     */
102 5
    public function setError($error)
103
    {
104 5
        $this->error = $error;
105 5
        return $this;
106
    }
107
108
    /**
109
     * @return int
110
     */
111 1
    public function getSize()
112
    {
113 1
        return $this->size;
114
    }
115
116
    /**
117
     * @param int $size
118
     * @return self
119
     */
120 5
    public function setSize($size)
121
    {
122 5
        $this->size = $size;
123 5
        return $this;
124
    }
125
126
    /**
127
     * @return string
128
     */
129 3
    public function getFileName()
130
    {
131 3
        return pathinfo($this->getName(), PATHINFO_FILENAME);
132
    }
133
134
    /**
135
     * @return string
136
     */
137 6
    public function getFileExtension()
138
    {
139 6
        return pathinfo($this->getName(), PATHINFO_EXTENSION);
140
    }
141
142
    /**
143
     * @return array
144
     */
145 1
    public function toArray()
146
    {
147
        return [
148 1
            'name'     => $this->getName(),
149 1
            'type'     => $this->getType(),
150 1
            'tmp_name' => $this->getTmpName(),
151 1
            'error'    => $this->getError(),
152 1
            'size'     => $this->getSize(),
153
        ];
154
    }
155
}
156