File::path()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: onysko
5
 * Date: 13.02.2015
6
 * Time: 15:46
7
 */
8
9
namespace samsonphp\upload;
10
11
12
class File
13
{
14
    /** @var string|boolean real file path */
15
    private $dir;
16
17
    /** @var string Original uploaded file name */
18
    private $original;
19
20
    /** @var string Generated file name */
21
    private $name;
22
23
    /** @var string File MIME type */
24
    private $mimeType;
25
26
    /** @var string extension */
27
    private $extension;
28
29
    /** @var int File size */
30
    private $size;
31
32
    /** @return string Get file directory without file name  */
33
    public function dir()
34
    {
35
        return $this->dir;
36
    }
37
38
    /** @return string Full path to file with file name */
39
    public function path()
40
    {
41
        return $this->dir.$this->name;
42
    }
43
44
    /** @return string Uploaded file name */
45
    public function original()
46
    {
47
        return $this->original;
48
    }
49
50
    /** @return string Uploaded new file name */
51
    public function name()
52
    {
53
        return $this->name;
54
    }
55
56
    /** @return string MIME type */
57
    public function mimeType()
58
    {
59
        return $this->mimeType;
60
    }
61
62
    /**
63
     * If $extension is set, tries to compare file extension to input extension and return a result
64
     * Otherwise returns file extension
65
     * @param string $extension Supposed file extension
66
     * @return bool|string Result of extension comparison or extension by itself.
67
     */
68
    public function extension($extension = null)
69
    {
70
        return isset($extension) ? ($extension === $this->extension ? true : false) : $this->extension;
71
    }
72
73
    /** @return int File size */
74
    public function size()
75
    {
76
        return $this->size;
77
    }
78
}
79