Passed
Push — main ( abc6af...1c0a46 )
by Tan
03:00
created

UserHasInteraction   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 4
c 1
b 0
f 1
dl 0
loc 11
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A like() 0 6 1
1
<?php
2
3
namespace CSlant\LaravelLike\Traits;
4
5
use Illuminate\Database\Eloquent\Relations\HasMany;
6
7
/**
8
 * Trait UserInteraction
9
 * use this trait in your User model
10
 *
11
 * @package CSlant\LaravelLike\Traits
12
 * @mixin \Illuminate\Database\Eloquent\Model
13
 */
14
trait UserHasInteraction
15
{
16
    /**
17
     * @return HasMany
18
     */
19
    public function like(): HasMany
20
    {
21
        $interactionModel = (string) (config('like.interaction_model') ?? 'CSlant\LaravelLike\Models\Like');
22
        $userForeignKey = (string) (config('like.users.foreign_key') ?? 'user_id');
23
24
        return $this->hasMany($interactionModel, $userForeignKey);
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $this->/** @scrutinizer ignore-call */ hasMany($interactionModel, $userForeignKey);
Loading history...
25
    }
26
}
27