IsometricAvatarController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A serveUuid() 0 7 1
A serveDefault() 0 7 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 IsometricAvatarController extends BaseApiController
11
{
12
    /**
13
     * Serve isometric avatar.
14
     *
15
     * @param string $uuid User UUID
16
     * @param int    $size
17
     *
18
     * @throws \Throwable
19
     */
20
    public function serveUuid(Request $request, string $uuid, $size = 0): Response
21
    {
22
        $this->uuidResolver->resolve($uuid);
23
        $this->dispatchAccountImageServedEvent();
24
25
        return $this->pngResponse(
26
            (string) $this->rendering->isometricAvatar($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_isometric_avatar', 3600, function () use ($size) {
38
            return (string) $this->rendering->isometricAvatar(null, (int) $size);
39
        });
40
41
        return $this->pngResponse($image);
42
    }
43
}
44