NoAuthController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 5
c 2
b 2
f 0
lcom 0
cbo 3
dl 0
loc 36
ccs 0
cts 21
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A showImage() 0 12 2
A getImg() 0 7 2
1
<?php
2
3
namespace plunner\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Http\Response;
7
use plunner\Http\Requests;
8
use plunner\Meeting;
9
10
class NoAuthController extends Controller
11
{
12
    public function __construct()
13
    {
14
    }
15
16
17
    //TODO remove this, it is just a tmp fix
18
    /**
19
     *
20
     * Store a newly created resource in storage.
21
     *
22
     * @param int $meetingId
23
     * @return static
24
     */
25
    public function showImage($meetingId)
26
    {
27
        $meeting = Meeting::findOrFail($meetingId);
28
        //$this->authorize($meeting);
29
        $ret = self::getImg($meeting);
30
        $blank = storage_path('img/meetings.jpg');
31
        if ($ret === false)
32
            return (new Response(file_get_contents($blank), 200))
33
                ->header('Content-Type', 'image/jpeg');
34
        return (new Response($ret, 200))
35
            ->header('Content-Type', 'image/jpeg');
36
    }
37
38
    private static function getImg(Meeting $meeting)
39
    {
40
        $name = 'meetings/' . $meeting->id;
41
        if (!\Storage::exists($name))
0 ignored issues
show
Bug introduced by
The method exists() does not seem to exist on object<Illuminate\Contracts\Filesystem\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
            return false;
43
        return \Storage::get($name);
44
    }
45
}
46