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 ( d735b0...21167e )
by Mark
02:16
created

Page::regenerateUrl()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 2
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Model;
4
5
use Carbon\Carbon;
6
use OwenIt\Auditing\Auditable;
7
use App\Classes\Interfaces\AuditInterface;
8
use Illuminate\Database\Eloquent\SoftDeletes;
9
use Illuminate\Database\Eloquent\Relations\BelongsTo;
10
use Illuminate\Database\Eloquent\Model as EloquentModel;
11
12
/**
13
 * Class Pages.
14
 *
15
 * @property Account getPublisher
16
 * @property Redirect redirect
17
 * @property Menu $menu
18
 *
19
 * @property int $id
20
 * @property string $slug
21
 * @property string $url
22
 * @property string $content
23
 * @property string $banner
24
 * @property string $seo_title
25
 * @property string $seo_description
26
 * @property string $seo_keywords
27
 * @property int $views
28
 * @property bool $sitemap
29
 * @property bool $enabled
30
 * @property string $plugin
31
 * @property int $editable
32
 * @property int $creator_id
33
 * @property int $editor_id
34
 *
35
 * @property Carbon $deleted_at
36
 * @property Carbon $created_at
37
 * @property Carbon $updated_at
38
 */
39
class Page extends EloquentModel implements AuditInterface
40
{
41
    /*
42
     * Laravel Deleting.
43
     * @ https://laravel.com/docs/5.5/eloquent#soft-deleting
44
     */
45
    use SoftDeletes;
46
    /*
47
     * Laravel Audits.
48
     * @ http://www.laravel-auditing.com
49
     */
50
    use Auditable;
51
52
    /**
53
     * The table associated with the model.
54
     *
55
     * @var string
56
     */
57
    protected $table = 'pages';
58
59
    /**
60
     * The attributes that are mass assignable.
61
     *
62
     * @var array
63
     */
64
    protected $fillable = ['seo_title', 'slug'];
65
66
    /**
67
     * The table date columns, casted to Carbon.
68
     *
69
     * @var array
70
     */
71
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
72
73
    /**
74
     * Attributes to exclude from the Audit.
75
     *
76
     * @var array
77
     */
78
    protected $auditExclude = [
79
        'views',
80
    ];
81
82
    /**
83
     * Increment the view count of the page.
84
     *
85
     * @return int
86
     */
87
    public function incrementViews()
88
    {
89
        return $this->views = $this->views + 1;
90
    }
91
92
    /**
93
     * A page belongs to a single menu.
94
     *
95
     * @return Menu|BelongsTo
96
     */
97
    public function menu()
98
    {
99
        return $this->belongsTo(Menu::class, 'id', 'page_id');
100
    }
101
102
    /**
103
     * A page can have a redirect to another url, external or internal.
104
     *
105
     * @return Redirect|\Illuminate\Database\Eloquent\Relations\HasOne
106
     */
107
    public function redirect()
108
    {
109
        return $this->hasOne(Redirect::class, 'from', 'id');
110
    }
111
112
    /**
113
     * Get the creator model of the eloquent model.
114
     *
115
     * @return Account|\Illuminate\Database\Eloquent\Relations\BelongsTo
116
     */
117
    public function creator()
118
    {
119
        return $this->belongsTo(Account::class, 'creator_id', 'id');
120
    }
121
122
    /**
123
     * Get the creator model of the eloquent model.
124
     *
125
     * @return Account|\Illuminate\Database\Eloquent\Relations\BelongsTo
126
     */
127
    public function editor()
128
    {
129
        return $this->belongsTo(Account::class, 'editor_id', 'id');
130
    }
131
132
    /**
133
     * Generate a link for the audit log.
134
     *
135
     * @return string
136
     */
137
    public function auditTitle()
138
    {
139
        return $this->seo_title;
140
    }
141
142
    /**
143
     * Generate a url to the audited data.
144
     *
145
     * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
146
     */
147
    public function auditUrl()
148
    {
149
        return route('admin.pages.edit', $this->slug);
0 ignored issues
show
Documentation introduced by
$this->slug is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
150
    }
151
152
    public function regenerateUrl()
153
    {
154
        if ($this->menu && $this->menu->parent) {
155
            return $this->url = sprintf('%s/%s', strtolower($this->menu->parent->title), $this->slug);
156
        }
157
158
        return $this->url = str_slug($this->seo_title);
159
    }
160
}
161