Passed
Push — master ( 10a915...0d23d6 )
by Mattia
08:28 queued 11s
created

DownloadTextureController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A serve() 0 11 1
A __construct() 0 6 1
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
    public function __construct(
30
        MinepicCore $minepic,
31
        ResponseFactory $responseFactory
32
    ) {
33
        $this->minepic = $minepic;
34
        $this->responseFactory = $responseFactory;
35
    }
36
37
    /**
38
     * Serve Avatar.
39
     *
40
     * @param \Illuminate\Http\Request
41
     *
42
     * @throws \Throwable
43
     */
44
    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

44
    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...
45
    {
46
        $headers = [
47
            'Content-Disposition' => 'Attachment;filename='.$uuidOrName.'.png',
48
            'Content-Type' => 'image/png',
49
        ];
50
        $this->minepic->initialize($uuidOrName);
51
        $avatarImage = $this->minepic->skinCurrentUser();
52
        $avatarImage->prepareTextureDownload();
53
54
        return $this->responseFactory->make($avatarImage, 200, $headers);
55
    }
56
}
57