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

SkinFrontController::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 SkinFrontController.
13
 */
14
class SkinFrontController extends BaseApiController
15
{
16
    /**
17
     * Serve Avatar.
18
     *
19
     * @param \Illuminate\Http\Request
20
     * @param string $uuid User UUID or Username
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
        $size = (int) $size;
30
        $this->uuidResolver->resolve($uuid);
31
        $this->dispatchAccountImageServedEvent();
32
33
        return $this->pngResponse(
34
            (string) $this->rendering->skin($this->uuidResolver->getUuid(), $size, ImageSection::FRONT)
35
        );
36
    }
37
38
    /**
39
     * @param int $size
40
     *
41
     * @throws \Throwable
42
     *
43
     * @return Response
44
     */
45
    public function serveDefault($size = 0): Response
46
    {
47
        return $this->pngResponse(
48
            (string) $this->rendering->skin(
49
                null,
50
                (int) $size,
51
                ImageSection::FRONT
52
            )
53
        );
54
    }
55
}
56