FineUploaderController::endpoint()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 0
1
<?php
2
3
/*
4
 * rmarchiv.tk
5
 * (c) 2016-2017 by Marcel 'ryg' Hering
6
 */
7
8
namespace App\Http\Controllers;
9
10
use Optimus\FineuploaderServer\Vendor\FineUploader;
11
12
/*
13
 * Hier muss ich mich erst einmal ein wenig durchwurschteln, da es dafür keine
14
 * Beispiele im Netz zu finden gibt...
15
 *
16
 * Aber wie sagt man so schön, selbst ist der Mann!
17
 */
18
19
class FineUploaderController extends Controller
20
{
21
    public function endpoint()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
22
    {
23
        $fu = new FineUploader();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
24
        $destpath = storage_path('app/public/temp');
25
        if (! file_exists($destpath)) {
26
            mkdir($destpath);
27
        }
28
        $res = $fu->handleUpload(storage_path('app/public/temp'), 'file');
29
30
        $res['ext'] = pathinfo($fu->getName(), PATHINFO_EXTENSION);
31
32
        return json_encode($res);
33
    }
34
}
35