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 ( 85cdf0...87050d )
by Mark
02:35
created

PageRepository::wherePlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Mark
5
 * Date: 04/03/2016
6
 * Time: 23:07.
7
 */
8
9
namespace App\Classes\Repositories;
10
11
use App\Model\Page;
12
use Illuminate\Support\Collection;
13
use Illuminate\Database\Eloquent\Builder;
14
15
/**
16
 * Class PageRepository.
17
 *
18
 * @method Page withTrashed
19
 */
20
class PageRepository extends BaseRepository
21
{
22
    /**
23
     * @var Page|Builder|Collection
24
     */
25
    protected $model;
26
27
    /**
28
     * PageRepository constructor.
29
     *
30
     * @param Page $model
31
     */
32
    public function __construct(Page $model)
33
    {
34
        $this->model = $model;
35
    }
36
37
    /**
38
     * @param $plugin_name
39
     * @return mixed
40
     */
41
    public function restoreTrashedPlugin($plugin_name)
42
    {
43
        return $this->model->withTrashed()->where('plugin', $plugin_name)->restore();
44
    }
45
46
    /**
47
     * @return mixed
48
     */
49
    public function makeList() : array
50
    {
51
        return $this->model->pluck('seo_title', 'id')->toArray();
0 ignored issues
show
Bug introduced by
The method pluck does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\Page.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
52
    }
53
54
    /**
55
     * @deprecated
56
     */
57
    public function listAllPagesWithoutMenusAndEditable()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
58
    {
59
        return $this->model->where('editable', true)->doesntHave('menu')->pluck('seo_title', 'id');
0 ignored issues
show
Bug introduced by
The method where does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\Page.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
60
    }
61
62
    public function listPagesWithoutMenus()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
63
    {
64
        return $this->model->doesntHave('menu')->get();
0 ignored issues
show
Bug introduced by
The method doesntHave does only exist in Illuminate\Database\Eloquent\Builder, but not in App\Model\Page and Illuminate\Support\Collection.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
65
    }
66
67
    public function allPagesWithoutMenusAndEditable() : Collection
68
    {
69
        return $this->model->where('editable', true)->doesntHave('menus')->get();
0 ignored issues
show
Bug introduced by
The method where does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\Page.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
70
    }
71
72
    /**
73
     * Get the page based on its name.
74
     *
75
     * @param $string
76
     * @return Page|array|\stdClass
77
     */
78
    public function whereName($string) : Page
79
    {
80
        return $this->model->where('slug', $string)->first();
0 ignored issues
show
Bug introduced by
The method where does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\Page.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
81
    }
82
83
    /**
84
     * @param $string
85
     * @return Page
86
     */
87
    public function whereRoute($string) : Page
88
    {
89
        return $this->model->where('route', $string)->first();
0 ignored issues
show
Bug introduced by
The method where does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\Page.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
90
    }
91
92
    /**
93
     * @param $string
94
     * @return Page
95
     */
96
    public function wherePlugin($string) : Page
97
    {
98
        return $this->model->where('plugin', $string)->first();
0 ignored issues
show
Bug introduced by
The method where does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\Page.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
99
    }
100
101
    /**
102
     * Sitemap enabled pages.
103
     */
104
    public function whereSitemap() : Collection
105
    {
106
        return $this->model->where('sitemap', true)->where('enabled', true)->get();
0 ignored issues
show
Bug introduced by
The method where does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\Page.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
107
    }
108
109
    /**
110
     * Return all pages that are enabled.
111
     */
112
    public function enabled() : Collection
113
    {
114
        return $this->model->where('enabled', true)->get();
0 ignored issues
show
Bug introduced by
The method where does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\Page.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
115
    }
116
117
    public function frontendPageCollection()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
118
    {
119
        return $this->model->with(['menu'])->get();
0 ignored issues
show
Bug introduced by
The method with does only exist in App\Model\Page and Illum...tabase\Eloquent\Builder, but not in Illuminate\Support\Collection.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
120
//        return $this->with(['menu' => function ($query) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
121
//            $query->with('parent');
122
//        }])->get();
123
    }
124
}
125