Passed
Push — dev ( 48fd2d...413832 )
by Mattia
03:24
created

DownloadTextureController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Http\Controllers\Api;
6
7
use App\Core as MinepicCore;
8
use Illuminate\Http\Request;
9
use Illuminate\Http\Response;
10
use Laravel\Lumen\Http\ResponseFactory;
11
use Laravel\Lumen\Routing\Controller as BaseController;
12
13
/**
14
 * Class BaseApiController.
15
 */
16
class DownloadTextureController extends BaseController
17
{
18
    /**
19
     * @var MinepicCore
20
     */
21
    protected $minepic;
22
23
    /** @var ResponseFactory */
24
    protected $responseFactory;
25
26
    /**
27
     * Api constructor.
28
     *
29
     * @param MinepicCore     $minepic
30
     * @param ResponseFactory $responseFactory
31
     */
32
    public function __construct(
33
        MinepicCore $minepic,
34
        ResponseFactory $responseFactory
35
    ) {
36
        $this->minepic = $minepic;
37
        $this->responseFactory = $responseFactory;
38
    }
39
40
    /**
41
     * Serve Avatar.
42
     *
43
     * @param \Illuminate\Http\Request
44
     * @param string $uuidOrName
45
     *
46
     * @return Response
47
     *
48
     * @throws \Throwable
49
     */
50
    public function serve(Request $request, string $uuidOrName = ''): Response
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

50
    public function serve(/** @scrutinizer ignore-unused */ Request $request, string $uuidOrName = ''): Response

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
    {
52
        $headers = [
53
            'Content-Disposition' => 'Attachment;filename='.$uuidOrName.'.png',
54
            'Content-Type' => 'image/png',
55
        ];
56
        $this->minepic->initialize($uuidOrName);
57
        $avatarImage = $this->minepic->skinCurrentUser();
58
        $avatarImage->prepareTextureDownload();
59
60
        return $this->responseFactory->make($avatarImage, 200, $headers);
61
    }
62
}
63