TagRelation::tag()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * rmarchiv.tk
5
 * (c) 2016-2017 by Marcel 'ryg' Hering
6
 */
7
8
namespace App\Models;
9
10
use Illuminate\Database\Eloquent\Model;
11
12
/**
13
 * Class TagRelation.
14
 *
15
 * @property int $id
16
 * @property int $tag_id
17
 * @property int $user_id
18
 * @property int $content_id
19
 * @property string $content_type
20
 * @property \Carbon\Carbon $created_at
21
 * @property \Carbon\Carbon $updated_at
22
 * @method static \Illuminate\Database\Query\Builder|\App\Models\TagRelation whereId($value)
23
 * @method static \Illuminate\Database\Query\Builder|\App\Models\TagRelation whereTagId($value)
24
 * @method static \Illuminate\Database\Query\Builder|\App\Models\TagRelation whereUserId($value)
25
 * @method static \Illuminate\Database\Query\Builder|\App\Models\TagRelation whereContentId($value)
26
 * @method static \Illuminate\Database\Query\Builder|\App\Models\TagRelation whereContentType($value)
27
 * @method static \Illuminate\Database\Query\Builder|\App\Models\TagRelation whereCreatedAt($value)
28
 * @method static \Illuminate\Database\Query\Builder|\App\Models\TagRelation whereUpdatedAt($value)
29
 * @mixin \Eloquent
30
 * @property-read \App\Models\Tag $tag
31
 * @property-read \Illuminate\Database\Eloquent\Collection|\Venturecraft\Revisionable\Revision[] $revisionHistory
32
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Game[] $games
33
 */
34 View Code Duplication
class TagRelation extends Model
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
{
36
    use \Venturecraft\Revisionable\RevisionableTrait;
37
    public $timestamps = true;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
38
    protected $table = 'tag_relations';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
39
    protected $fillable = [
40
        'tag_id',
41
        'user_id',
42
        'content_id',
43
        'content_type',
44
    ];
45
46
    protected $guarded = [];
47
48
    public function tag()
49
    {
50
        return $this->hasOne('App\Models\Tag', 'id', 'tag_id');
51
    }
52
53
    public function games()
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...
54
    {
55
        return $this->hasMany('App\Models\Game', 'id', 'content_id')->Where('content_type', '=', \DB::raw("'game'"));
56
    }
57
}
58