LinksController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 46
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 4 1
A show() 0 6 1
A destroy() 0 10 2
1
<?php
2
3
namespace App\Http\Controllers\Admin;
4
5
use App\Http\Requests\Admin\LinksRequest;
6
use App\Session\Flash;
7
use Illuminate\Http\Request;
8
use App\Http\Controllers\Controller;
9
use App\Link;
10
use App\Hit;
11
12
class LinksController extends Controller
13
{
14
    /**
15
     * Display a listing of the resource.
16
     *
17
     * @return \Illuminate\Http\Response
18
     */
19
    public function index()
20
    {
21
        return view('admin.links.index', ['links' => Link::paginate(config('myio.admin.pagination.items_per_page'))]);
22
    }
23
24
    /**
25
     * Display the specified resource.
26
     *
27
     * @param Link $link
28
     *
29
     * @return \Illuminate\Http\Response
30
     * @internal param int $id
31
     */
32
    public function show(Link $link)
33
    {
34
        $hits = Hit::where('link_id', $link->id)->paginate(config('myio.admin.pagination.items_per_page'));
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Link>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
35
36
        return view('admin.links.show', compact('link', 'hits'));
37
    }
38
39
    /**
40
     * Remove the specified resource from storage.
41
     *
42
     * @param Link $link
43
     *
44
     * @return \Illuminate\Http\Response
45
     * @internal param int $id
46
     */
47
    public function destroy(Link $link)
48
    {
49
        if ($link->delete()) {
50
            Flash::success('Link deleted.');
51
        } else {
52
            Flash::error('Could not delete this link.');
53
        }
54
55
        return redirect()->route('admin.links.index');
56
    }
57
}
58