Passed
Push — master ( 6ffe87...662eee )
by Mattia
03:26
created

Rendering::isometricAvatar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 2
dl 0
loc 11
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Image;
6
7
use App\Image\Sections\Avatar;
8
use App\Image\Sections\Skin;
9
10
class Rendering
11
{
12
    /**
13
     * @param string $imagePath
14
     * @param int    $size
15
     * @param string $type
16
     *
17
     * @throws Exceptions\ImageCreateFromPngFailedException
18
     * @throws Exceptions\ImageTrueColorCreationFailedException
19
     * @throws Exceptions\InvalidSectionSpecifiedException
20
     *
21
     * @return Avatar
22
     */
23
    public function avatar(string $imagePath, int $size, $type = ImageSection::FRONT): Avatar
24
    {
25
        $avatar = new Avatar($imagePath);
26
        $avatar->render($size, $type);
27
28
        return $avatar;
29
    }
30
31
    public function isometricAvatar(string $imagePath, int $size): IsometricAvatar
0 ignored issues
show
Unused Code introduced by
The parameter $imagePath is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

31
    public function isometricAvatar(/** @scrutinizer ignore-unused */ string $imagePath, int $size): IsometricAvatar

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        $uuid = $this->userdata->uuid ?? env('DEFAULT_UUID');
0 ignored issues
show
Bug Best Practice introduced by
The property userdata does not exist on App\Image\Rendering. Did you maybe forget to declare it?
Loading history...
34
        $timestamp = $this->userdata->updated_at->timestamp ?? \time();
35
        $isometricAvatar = new IsometricAvatar(
36
            $uuid,
37
            $timestamp
38
        );
39
        $isometricAvatar->render($size);
40
41
        return $isometricAvatar;
42
    }
43
44
    /**
45
     * @param string $imagePath
46
     * @param int    $size
47
     * @param string $type
48
     *
49
     * @throws \Throwable
50
     *
51
     * @return Skin
52
     */
53
    public function skin(string $imagePath, int $size, $type = ImageSection::FRONT): Skin
54
    {
55
        $skin = new Skin($imagePath);
56
        $skin->render($size, $type);
57
58
        return $skin;
59
    }
60
}
61