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 ( 70e47f...dda101 )
by Mark
07:55
created

ArticleRepository   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 127
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 127
rs 10
c 0
b 0
f 0
wmc 14
lcom 1
cbo 1

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A whereSitemappable() 0 4 1
A latest() 0 4 1
A mostViewed() 0 4 1
A uniqueCreators() 0 4 1
A viewable() 0 4 1
A paginateLatest() 0 4 1
A activeCategories() 0 4 1
A publishedArticlesCount() 0 4 1
A whereStatusActive() 0 4 1
A collectArticle() 0 4 1
A searchThenPaginate() 0 4 1
A whereCreatorId() 0 4 1
A whereCategoryId() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Marky
5
 * Date: 16/02/2018
6
 * Time: 16:00
7
 */
8
9
namespace App\Classes\Repositories;
10
11
use App\Model\Article;
12
use App\Model\Menu;
13
use Illuminate\Support\Collection;
14
use Illuminate\Database\Eloquent\Builder;
15
use Illuminate\Database\Eloquent\Relations\HasMany;
16
17
18
/**
19
 * Class ArticleRepository
20
 *
21
 * @package App\Classes\Repositories
22
 */
23
class ArticleRepository extends BaseRepository
24
{
25
    /**
26
     * @var Article|Builder|Collection
27
     */
28
    protected $model;
29
30
    /**
31
     * PageRepository constructor.
32
     *
33
     * @param Article|Menu $model
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $model a bit more specific; maybe use Article.
Loading history...
34
     */
35
    public function __construct(Article $model)
36
    {
37
        $this->model = $model;
38
    }
39
40
    public function whereSitemappable()
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...
41
    {
42
        return $this->model->where(['sitemap' => true, 'status' => 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\Article.

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...
43
    }
44
45
    /**
46
     * @ver 5.0.2
47
     * @date 08/03/2018
48
     * @param int $count
49
     * @return \Illuminate\Database\Eloquent\Collection|Collection|static[]
50
     */
51
    public function latest($count = 7)
52
    {
53
        return $this->model->take($count)->where('status', Article::STATUS_PUBLISHED)->orderBy('created_at', 'desc')->get();
0 ignored issues
show
Bug introduced by
The method take does only exist in Illuminate\Support\Collection, but not in App\Model\Article and Il...tabase\Eloquent\Builder.

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...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 124 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
54
    }
55
56
    /**
57
     * @ver 5.0.2
58
     * @date 08/03/2018
59
     * @param int $count
60
     * @return \Illuminate\Database\Eloquent\Collection|Collection|static[]
61
     */
62
    public function mostViewed($count = 7)
63
    {
64
        return $this->model->orderBy('views', 'desc')->take($count)->where('status', Article::STATUS_PUBLISHED)->get();
65
    }
66
67
    /**
68
     * @ver 5.1.13
69
     * @date 19/03/2018
70
     * @return mixed
71
     */
72
    public function uniqueCreators()
73
    {
74
        return $this->model->all()->unique('creator_id');
0 ignored issues
show
Bug introduced by
The method all does only exist in App\Model\Article and Il...nate\Support\Collection, but not in Illuminate\Database\Eloquent\Builder.

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...
75
    }
76
77
    /**
78
     * @ver 5.1.14
79
     * @date 19/03/2018
80
     * @return mixed
81
     */
82
    public function viewable()
83
    {
84
        return $this->model->where('status', Article::STATUS_PUBLISHED)->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\Article.

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...
85
    }
86
87
    /**
88
     * @param int $count
89
     * @return \Illuminate\Contracts\Pagination\Paginator
90
     */
91
    public function paginateLatest(int $count)
92
    {
93
        return $this->model->orderBy('created_at', 'desc')->where('status', Article::STATUS_PUBLISHED)->simplePaginate($count);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
94
    }
95
96
    /**
97
     * @ver 5.1.13
98
     * @date 19/03/2018
99
     * @return mixed
100
     */
101
    public function activeCategories()
102
    {
103
        return app(ArticleCategoryRepository::class)->whereStatusActive();
104
    }
105
106
    /**
107
     * @ver 5.1.15
108
     * @date 19/03/2018
109
     * @param int $creator_id
110
     * @return integer
111
     */
112
    public function publishedArticlesCount(int $creator_id)
0 ignored issues
show
Coding Style Naming introduced by
The parameter $creator_id is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
113
    {
114
        return $this->model->where('status', Article::STATUS_PUBLISHED)->where('creator_id', $creator_id)->count();
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\Article.

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
    /**
118
     * @return \Illuminate\Database\Eloquent\Collection|mixed|static[]
119
     */
120
    public function whereStatusActive()
121
    {
122
        return $this->model->where('status', 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\Article.

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...
123
    }
124
125
    public function collectArticle(string $slug)
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...
126
    {
127
        return $this->model->where('slug', $slug)->where('status', Article::STATUS_PUBLISHED)->orderBy('created_at', 'desc')->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\Article.

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...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 134 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
128
    }
129
130
    /**
131
     * @param string $text
132
     * @param int $paginate
133
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
134
     */
135
    public function searchThenPaginate(string $text, int $paginate = 7)
136
    {
137
        return $this->model->search($text)->orderBy('created_at', 'desc')->where('status', Article::STATUS_PUBLISHED)->paginate($paginate);
0 ignored issues
show
Bug introduced by
The method search does only exist in Illuminate\Support\Collection, but not in App\Model\Article and Il...tabase\Eloquent\Builder.

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...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 139 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
138
    }
139
140
    public function whereCreatorId(int $creator_id, int $paginate = 5)
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...
Coding Style Naming introduced by
The parameter $creator_id is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
141
    {
142
        return $this->model->orderBy('created_at', 'desc')->where('creator_id', $creator_id)->where('status', Article::STATUS_PUBLISHED)->simplePaginate($paginate);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 164 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
143
    }
144
145
    public function whereCategoryId(int $id, int $paginate = 5)
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...
146
    {
147
        return $this->model->where('category_id', $id)->where('status', Article::STATUS_PUBLISHED)->orderBy('created_at', 'desc')->simplePaginate($paginate);
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\Article.

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...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 157 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
148
    }
149
}