Passed
Branch master (8656ae)
by refat
03:19
created
Core/System/Http/UploadeFile.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -6,115 +6,115 @@
 block discarded – undo
6 6
 
7 7
 class UploadeFile
8 8
 {
9
-  private $app;
9
+	private $app;
10 10
 
11
-  private $file = [];
11
+	private $file = [];
12 12
 
13
-  private $fileName;
13
+	private $fileName;
14 14
 
15
-  private $nameOnly;
15
+	private $nameOnly;
16 16
 
17
-  private $extension;
17
+	private $extension;
18 18
 
19
-  private $minetype;
19
+	private $minetype;
20 20
 
21
-  private $tempFile;
21
+	private $tempFile;
22 22
 
23
-  private $size;
23
+	private $size;
24 24
 
25
-  private $error;
25
+	private $error;
26 26
 
27
-  private const AllOW_EXTENSION = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
27
+	private const AllOW_EXTENSION = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
28 28
 
29
-  public function __construct(Application $app, $input)
30
-  {
31
-    $this->app = $app;
29
+	public function __construct(Application $app, $input)
30
+	{
31
+		$this->app = $app;
32 32
 
33
-    $this->getFileInfo($input);
34
-  }
33
+		$this->getFileInfo($input);
34
+	}
35 35
 
36
-  private function getFileInfo($input)
37
-  {
38
-    if (empty($_FILES[$input])) return;
36
+	private function getFileInfo($input)
37
+	{
38
+		if (empty($_FILES[$input])) return;
39 39
 
40
-    $file = $_FILES[$input];
40
+		$file = $_FILES[$input];
41 41
 
42
-    $this->error = $file['error'];
42
+		$this->error = $file['error'];
43 43
 
44
-    if ($this->error != UPLOAD_ERR_OK) return;
44
+		if ($this->error != UPLOAD_ERR_OK) return;
45 45
 
46
-    $this->file = $file;
46
+		$this->file = $file;
47 47
 
48
-    $this->fileName = $this->file['name'];
48
+		$this->fileName = $this->file['name'];
49 49
 
50
-    $this->minetype = $this->file['type'];
50
+		$this->minetype = $this->file['type'];
51 51
 
52
-    $this->size = $this->file['size'];
52
+		$this->size = $this->file['size'];
53 53
 
54
-    $this->tempFile = $this->file['tmp_name'];
54
+		$this->tempFile = $this->file['tmp_name'];
55 55
 
56
-    $fileInfo = pathinfo($this->fileName);
56
+		$fileInfo = pathinfo($this->fileName);
57 57
 
58
-    $this->nameOnly = $fileInfo['filename'];
58
+		$this->nameOnly = $fileInfo['filename'];
59 59
 
60
-    $this->extension = $fileInfo['extension'];
61
-  }
60
+		$this->extension = $fileInfo['extension'];
61
+	}
62 62
 
63
-  public function exists()
64
-  {
65
-    return ! empty($this->file);
66
-  }
63
+	public function exists()
64
+	{
65
+		return ! empty($this->file);
66
+	}
67 67
 
68
-  public function getFileName()
69
-  {
70
-    return $this->fileName;
71
-  }
68
+	public function getFileName()
69
+	{
70
+		return $this->fileName;
71
+	}
72 72
 
73
-  public function getNameOnly()
74
-  {
75
-    return $this->nameOnly;
76
-  }
73
+	public function getNameOnly()
74
+	{
75
+		return $this->nameOnly;
76
+	}
77 77
 
78
-  public function getExtension()
79
-  {
80
-    return $this->extension;
81
-  }
78
+	public function getExtension()
79
+	{
80
+		return $this->extension;
81
+	}
82 82
 
83
-  public function getMinetype()
84
-  {
85
-    return $this->minetype;
86
-  }
83
+	public function getMinetype()
84
+	{
85
+		return $this->minetype;
86
+	}
87 87
 
88
-  public function getSize()
89
-  {
90
-    return $this->size;
91
-  }
88
+	public function getSize()
89
+	{
90
+		return $this->size;
91
+	}
92 92
 
93
-  public function getTempFile()
94
-  {
95
-    return $this->tempFile;
96
-  }
93
+	public function getTempFile()
94
+	{
95
+		return $this->tempFile;
96
+	}
97 97
 
98
-  public function isImage()
99
-  {
100
-    return strpos($this->minetype, 'image/') === 0 && in_array($this->extension, self::AllOW_EXTENSION);
101
-  }
98
+	public function isImage()
99
+	{
100
+		return strpos($this->minetype, 'image/') === 0 && in_array($this->extension, self::AllOW_EXTENSION);
101
+	}
102 102
 
103
-  public function moveTo($target, $newName = null)
104
-  {
105
-    $newName = $newName ?: sha1(rand()) . sha1(rand());
103
+	public function moveTo($target, $newName = null)
104
+	{
105
+		$newName = $newName ?: sha1(rand()) . sha1(rand());
106 106
 
107
-    $newName .= '.' . $this->extension;
107
+		$newName .= '.' . $this->extension;
108 108
 
109
-    if (! is_dir($target)) mkdir($target, 0777, true);
109
+		if (! is_dir($target)) mkdir($target, 0777, true);
110 110
 
111
-    $filePath = $target . $newName;
111
+		$filePath = $target . $newName;
112 112
 
113
-    $filePath  = rtrim($filePath, '/');
114
-    $filePath  = ltrim($filePath, '/');
113
+		$filePath  = rtrim($filePath, '/');
114
+		$filePath  = ltrim($filePath, '/');
115 115
 
116
-    $uploade = move_uploaded_file($this->tempFile, $filePath);
116
+		$uploade = move_uploaded_file($this->tempFile, $filePath);
117 117
 
118
-    return $uploade;
119
-  }
118
+		return $uploade;
119
+	}
120 120
 }
121 121
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,13 +35,17 @@  discard block
 block discarded – undo
35 35
 
36 36
   private function getFileInfo($input)
37 37
   {
38
-    if (empty($_FILES[$input])) return;
38
+    if (empty($_FILES[$input])) {
39
+    	return;
40
+    }
39 41
 
40 42
     $file = $_FILES[$input];
41 43
 
42 44
     $this->error = $file['error'];
43 45
 
44
-    if ($this->error != UPLOAD_ERR_OK) return;
46
+    if ($this->error != UPLOAD_ERR_OK) {
47
+    	return;
48
+    }
45 49
 
46 50
     $this->file = $file;
47 51
 
@@ -106,7 +110,9 @@  discard block
 block discarded – undo
106 110
 
107 111
     $newName .= '.' . $this->extension;
108 112
 
109
-    if (! is_dir($target)) mkdir($target, 0777, true);
113
+    if (! is_dir($target)) {
114
+    	mkdir($target, 0777, true);
115
+    }
110 116
 
111 117
     $filePath = $target . $newName;
112 118
 
Please login to merge, or discard this patch.