SkinFrontController::serveDefault()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 10
rs 10
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
10
class SkinFrontController extends BaseApiController
11
{
12
    /**
13
     * @param string $uuid User UUID or Username
14
     * @param int    $size
15
     *
16
     * @throws \Throwable
17
     */
18
    public function serveUuid(Request $request, string $uuid, $size = 0): Response
19
    {
20
        $size = (int) $size;
21
        $this->uuidResolver->resolve($uuid);
22
        $this->dispatchAccountImageServedEvent();
23
24
        return $this->pngResponse(
25
            (string) $this->rendering->skinFront($this->uuidResolver->getUuid(), $size)
26
        );
27
    }
28
29
    /**
30
     * @param int|string $size
31
     *
32
     * @throws \Throwable
33
     */
34
    public function serveDefault($size = 0): Response
35
    {
36
        $image = $this->cache()->remember('rendering.system.default_skin_front', 3600, function () use ($size) {
37
            return (string) $this->rendering->skinFront(
38
                null,
39
                (int) $size
40
            );
41
        });
42
43
        return $this->pngResponse($image);
44
    }
45
}
46