Passed
Push — master ( 9aa048...898b5e )
by Mattia
04:05
created

SkinBackController::serveDefault()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Minepic\Http\Controllers\Api;
6
7
use Illuminate\Http\Request;
8
use Illuminate\Http\Response;
9
use Minepic\Image\ImageSection;
10
11
/**
12
 * Class BaseApiController.
13
 */
14
class SkinBackController extends BaseApiController
15
{
16
    /**
17
     * Serve Avatar.
18
     *
19
     * @param \Illuminate\Http\Request
20
     * @param string $uuid User UUID
21
     * @param int    $size
22
     *
23
     * @throws \Throwable
24
     *
25
     * @return \Illuminate\Http\Response
26
     */
27
    public function serveUuid(Request $request, $uuid, $size = 0): Response
28
    {
29
        $this->uuidResolver->resolve($uuid);
30
        $this->dispatchAccountImageServedEvent();
31
32
        return $this->pngResponse(
33
            (string) $this->rendering->skin($this->uuidResolver->getUuid(), (int) $size, ImageSection::BACK)
34
        );
35
    }
36
37
    /**
38
     * @param int $size
39
     *
40
     * @throws \Throwable
41
     *
42
     * @return Response
43
     */
44
    public function serveDefault($size = 0): Response
45
    {
46
        return $this->pngResponse(
47
            (string) $this->rendering->skin(
48
                null,
49
                (int) $size,
50
                ImageSection::BACK
51
            )
52
        );
53
    }
54
}
55