Completed
Push — master ( 25c873...2076b7 )
by Afshin
02:25
created

File   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A moveUploadedFile() 0 7 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: afshin
5
 * Date: 11/24/17
6
 * Time: 1:11 PM
7
 */
8
9
namespace Core\Services;
10
11
use Core\Interfaces\_Service;
12
use Slim\Http\UploadedFile;
13
14
class File extends _Service
15
{
16
	public function moveUploadedFile($directory,$fileName, UploadedFile $uploadedFile)
17
	{
18
	    $extension = pathinfo($uploadedFile->getClientFilename(), PATHINFO_EXTENSION);
19
	    $basename = bin2hex(random_bytes(8)); // see http://php.net/manual/en/function.random-bytes.php
0 ignored issues
show
Unused Code introduced by
The assignment to $basename is dead and can be removed.
Loading history...
20
	    $filename = sprintf('%s.%0.8s', $fileName, $extension);
21
	    $uploadedFile->moveTo($directory . DIRECTORY_SEPARATOR . $filename);
22
	    return $filename;
23
	}
24
25
}