GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( fe87e3...aa9b3c )
by Damian
16:15
created

FileUploader::generateHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Uploader;
4
5
use Symfony\Component\HttpFoundation\File\UploadedFile;
6
use Symfony\Component\HttpFoundation\File\File;
7
use App\Model\FileCollection;
8
9
class FileUploader
10
{
11
    /**
12
     * Moves UploadedFile to new location.
13
     *
14
     * @param UploadedFile $file
15
     * @param FileCollection $fileCollection
16
     * @return File
17
     */
18
    public function upload(UploadedFile $file, FileCollection $fileCollection)
19
    {
20
        return $file->move(
21
            $fileCollection->getDirectory(),
22
            $this->generateFileName($file)
23
        );
24
    }
25
26
    private function generateFileName(UploadedFile $file)
27
    {
28
        $baseFilename = str_replace('.' . $file->getClientOriginalExtension(), null, $file->getClientOriginalName());
29
        $baseFilename = preg_replace("/[^a-zA-Z0-9_-]/", '', $baseFilename);
30
31
        return $this->generateHash() . '-' .$baseFilename . '.' . $file->guessExtension();
32
    }
33
34
    private function generateHash()
35
    {
36
        return substr(md5(microtime() . uniqid(rand(), true) . 'salt'), 0, 8);
37
    }
38
}
39