SkinBackController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A serveUuid() 0 7 1
A serveDefault() 0 10 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 SkinBackController extends BaseApiController
11
{
12
    /**
13
     * Serve Avatar.
14
     *
15
     * @param string $uuid User UUID
16
     * @param int    $size
17
     *
18
     * @throws \Throwable
19
     */
20
    public function serveUuid(Request $request, $uuid, $size = 0): Response
21
    {
22
        $this->uuidResolver->resolve($uuid);
23
        $this->dispatchAccountImageServedEvent();
24
25
        return $this->pngResponse(
26
            (string) $this->rendering->skinBack($this->uuidResolver->getUuid(), (int) $size)
27
        );
28
    }
29
30
    /**
31
     * @param int|string $size
32
     *
33
     * @throws \Throwable
34
     */
35
    public function serveDefault($size = 0): Response
36
    {
37
        $image = $this->cache()->remember('rendering.system.default_skin_back', 3600, function () use ($size) {
38
            return (string) $this->rendering->skinBack(
39
                null,
40
                (int) $size
41
            );
42
        });
43
44
        return $this->pngResponse($image);
45
    }
46
}
47