TicketReference   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 67.74 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 21
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTable() 4 4 1
A ticket() 4 4 1
A referenceable() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
4
namespace RexlManu\LaravelTickets\Models;
5
6
7
use Illuminate\Database\Eloquent\Model;
8
use RexlManu\LaravelTickets\Traits\HasConfigModel;
9
10
/**
11
 * Class TicketReference
12
 *
13
 * Used to reference a specific model to a ticket
14
 *
15
 * @package RexlManu\LaravelTickets\Models
16
 */
17 View Code Duplication
class TicketReference 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...
18
{
19
20
    use HasConfigModel;
21
22
    public function getTable()
23
    {
24
        return config('laravel-tickets.database.ticket-references-table');
25
    }
26
27
    /**
28
     * Gives the ticket that belongs to it
29
     *
30
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
31
     */
32
    public function ticket()
33
    {
34
        return $this->belongsTo(Ticket::class);
35
    }
36
37
    /**
38
     * Gives the model that is declared as reference
39
     *
40
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
41
     */
42
    public function referenceable()
43
    {
44
        return $this->morphTo();
45
    }
46
47
}
48