Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 6bda91...26ffdc )
by Cristian
03:56 queued 24s
created

Show   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B show() 0 35 6
1
<?php
2
3
namespace Backpack\CRUD\app\Http\Controllers\Operations;
4
5
trait Show
6
{
7
    /**
8
     * Display the specified resource.
9
     *
10
     * @param int $id
11
     *
12
     * @return Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
13
     */
14
    public function show($id)
15
    {
16
        $this->crud->hasAccessOrFail('show');
0 ignored issues
show
Bug introduced by
The property crud does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
18
        // get entry ID from Request (makes sure its the last ID for nested resources)
19
        $id = $this->crud->getCurrentEntryId() ?? $id;
20
21
        // set columns from db
22
        $this->crud->setFromDb();
23
24
        // cycle through columns
25
        foreach ($this->crud->columns as $key => $column) {
26
            // remove any autoset relationship columns
27
            if (array_key_exists('model', $column) && array_key_exists('autoset', $column) && $column['autoset']) {
28
                $this->crud->removeColumn($column['name']);
29
            }
30
31
            // remove the row_number column, since it doesn't make sense in this context
32
            if ($column['type'] == 'row_number') {
33
                $this->crud->removeColumn($column['name']);
34
            }
35
        }
36
37
        // get the info for that entry
38
        $this->data['entry'] = $this->crud->getEntry($id);
0 ignored issues
show
Bug introduced by
The property data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
39
        $this->data['crud'] = $this->crud;
40
        $this->data['title'] = trans('backpack::crud.preview').' '.$this->crud->entity_name;
41
42
        // remove preview button from stack:line
43
        $this->crud->removeButton('preview');
44
        $this->crud->removeButton('delete');
45
46
        // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
47
        return view($this->crud->getShowView(), $this->data);
48
    }
49
}
50