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

AvatarController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A serveUuid() 0 9 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 AvatarController extends BaseApiController
11
{
12
    /**
13
     * Serve Avatar.
14
     *
15
     * @param \Illuminate\Http\Request
16
     * @param string $uuid
17
     * @param int    $size
18
     *
19
     * @throws \Throwable
20
     *
21
     * @return \Illuminate\Http\Response
22
     */
23
    public function serveUuid(Request $request, string $uuid, $size = 0): Response
24
    {
25
        $this->uuidResolver->resolve($uuid);
26
        $this->dispatchAccountImageServedEvent();
27
28
        return $this->pngResponse(
29
            (string) $this->rendering->avatar(
30
                $this->uuidResolver->getUuid(),
31
                (int) $size
32
            )
33
        );
34
    }
35
36
    /**
37
     * @param int $size
38
     *
39
     * @throws \Minepic\Image\Exceptions\ImageCreateFromPngFailedException
40
     * @throws \Minepic\Image\Exceptions\ImageTrueColorCreationFailedException
41
     * @throws \Minepic\Image\Exceptions\InvalidSectionSpecifiedException
42
     *
43
     * @return Response
44
     */
45
    public function serveDefault($size = 0): Response
46
    {
47
        return $this->pngResponse(
48
            (string) $this->rendering->avatar(
49
                null,
50
                (int) $size
51
            )
52
        );
53
    }
54
}
55