LaravelFastComments   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A commentator() 0 4 1
A getAuthModelName() 0 7 2
1
<?php
2
3
namespace Axitdev\LaravelFastComments;
4
5
use Exception;
6
use Illuminate\Database\Eloquent\Model;
7
8
class LaravelFastComments extends Model
9
{
10
    /**
11
     * The table associated with the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'comments';
16
	
17
	/**
18
     * The attributes that are mass assignable.
19
     *
20
     * @var array
21
     */
22
    protected $fillable = [
23
        'comment', 'user_id',
24
    ];
25
26
    /**
27
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
28
     * @throws Exception
29
     */
30
    public function commentator()
31
    {
32
        return $this->belongsTo($this->getAuthModelName(), 'user_id');
33
    }
34
35
    /**
36
     * @return \Illuminate\Config\Repository|mixed
37
     * @throws Exception
38
     */
39
    protected function getAuthModelName()
40
    {
41
        if (!is_null(config('auth.providers.users.model'))) {
42
            return config('auth.providers.users.model');
43
        }
44
        throw new Exception('Could not determine the commentator model name.');
45
    }
46
}
47