ImagingController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 57
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getYoutubeThumbnail() 0 4 1
A getUserBody() 0 4 1
A getGroupBadge() 0 8 1
A getUserHead() 0 5 2
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Models\EmulatorSettings;
6
use App\Models\User;
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\Config;
9
use Intervention\Image\Facades\Image;
10
use Laravel\Lumen\Http\Redirector;
11
use Laravel\Lumen\Routing\Controller as BaseController;
12
13
/**
14
 * Class ImagingController.
15
 */
16
class ImagingController extends BaseController
17
{
18
    /**
19
     * Get User Figure for Big Header
20
     * based on User Name or Figure.
21
     *
22
     * @param Request $request
23
     *
24
     * @return Redirector
25
     */
26
    public function getUserHead(Request $request)
27
    {
28
        return redirect(Config::get('chocolatey.imaging').'avatarimage?figure='.($request->has('figure') ? $request->input('figure') :
0 ignored issues
show
Bug Compatibility introduced by
The expression redirect(\Illuminate\Sup... '&size=l&headonly=1'); of type Laravel\Lumen\Http\Redir...e\Http\RedirectResponse adds the type Illuminate\Http\RedirectResponse to the return on line 28 which is incompatible with the return type documented by App\Http\Controllers\Ima...Controller::getUserHead of type Laravel\Lumen\Http\Redirector.
Loading history...
29
                User::where('username', $request->input('user'))->first()->figureString).'&size=l&headonly=1');
30
    }
31
32
    /**
33
     * Get User Figure for Body
34
     * based on User Figure.
35
     *
36
     * @param string $figure
37
     *
38
     * @return Redirector
39
     */
40
    public function getUserBody(string $figure)
41
    {
42
        return redirect(Config::get('chocolatey.imaging')."avatar/{$figure}");
0 ignored issues
show
Bug Compatibility introduced by
The expression redirect(\Illuminate\Sup... . "avatar/{$figure}"); of type Laravel\Lumen\Http\Redir...e\Http\RedirectResponse adds the type Illuminate\Http\RedirectResponse to the return on line 42 which is incompatible with the return type documented by App\Http\Controllers\Ima...Controller::getUserBody of type Laravel\Lumen\Http\Redirector.
Loading history...
43
    }
44
45
    /**
46
     * Get Youtube Thumbnail.
47
     *
48
     * @param Request $request
49
     *
50
     * @return string
51
     */
52
    public function getYoutubeThumbnail(Request $request)
53
    {
54
        return Image::make($request->input('url'))->response('jpg');
55
    }
56
57
    /**
58
     * Return Group Badge.
59
     *
60
     * @param string $badgeCode
61
     *
62
     * @return mixed
63
     */
64
    public function getGroupBadge(string $badgeCode)
65
    {
66
        $imagePath = EmulatorSettings::where('key', 'imager.location.output.badges')->first();
67
68
        $badgeCode = str_replace('.gif', '', $badgeCode);
69
70
        return Image::make("{$imagePath->value}/{$badgeCode}.png")->response('gif');
71
    }
72
}
73