ColorBlockController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 36
ccs 7
cts 8
cp 0.875
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 3
1
<?php
2
3
namespace Limsum\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Limsum\ColorBlock\ColorBlockMaker;
7
8
class ColorBlockController extends LimsumController
9
{
10
11
    /**
12
     * @var string
13
     */
14
    public static string $withParameterName = 'w';
15
16
    /**
17
     * @var string
18
     */
19
    public static string $heightParameterName = 'h';
20
21
    /**
22
     * @var string
23
     */
24
    public static string $colorParameterName = 'c';
25
26
    /**
27
     * @param  string  $extension
28
     * @param  Request  $request
29
     *
30
     * @return mixed
31
     */
32 2
    public function __invoke(string $extension, Request $request)
33
    {
34 2
        if (! in_array($extension, config('lorem-image.drivers.color-block.extensions', []))) {
35
            abort(404);
36
        }
37
38 2
        return (new ColorBlockMaker(
39
            $extension,
40 2
            $request->get(static::$withParameterName, 100) ?? 100,
41 2
            $request->get(static::$heightParameterName, 100) ?? 100,
42 2
            $request->get(static::$colorParameterName, '#808080') ?: '#808080',
43 2
        ))->image();
44
    }
45
}
46