Completed
Push — fixes ( 6830e4...798510 )
by Tony
03:34
created

IPv4   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 1
dl 47
loc 47
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A port() 4 4 1
A device() 4 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
 * app/Models/General/IPv4.php
4
 *
5
 * Model for IPv4 Search
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Neil Lathwood
23
 * @author     Neil Lathwood <[email protected]>
24
 */
25
26
namespace App\Models\General;
27
28
use Illuminate\Database\Eloquent\Model;
29
use Illuminate\Database\Eloquent\Builder;
30
31
/**
32
 * App\Models\General\IPv4
33
 *
34
 * @property integer $ipv4_address_id
35
 * @property string $ipv4_address
36
 * @property integer $ipv4_prefixlen
37
 * @property string $ipv4_network_id
38
 * @property integer $port_id
39
 * @property string $context_name
40
 * @property-read \App\Models\Port $port
41
 * @property-read \App\Models\Device $device
42
 * @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereIpv4AddressId($value)
43
 * @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereIpv4Address($value)
44
 * @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereIpv4Prefixlen($value)
45
 * @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereIpv4NetworkId($value)
46
 * @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 wherePortId($value)
47
 * @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereContextName($value)
48
 * @mixin \Eloquent
49
 */
50 View Code Duplication
class IPv4 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...
51
{
52
53
    protected $hidden = ['ip'];
54
55
    /**
56
     * Indicates if the model should be timestamped.
57
     *
58
     * @var bool
59
     */
60
    public $timestamps = false;
61
    /**
62
     * The table associated with the model.
63
     *
64
     * @var string
65
     */
66
    protected $table = 'ipv4_addresses';
67
    /**
68
     * The primary key column name.
69
     *
70
     * @var string
71
     */
72
    protected $primaryKey = 'ipv4_address_id';
73
74
75
    // ---- Accessors/Mutators ----
76
77
78
    // ---- Define Reletionships ----
79
80
    /**
81
     * Returns the port this entry belongs to.
82
     */
83
    public function port()
84
    {
85
        return $this->belongsTo('App\Models\Port', 'port_id', 'port_id');
86
    }
87
88
    /**
89
     * Returns the device this entry belongs to.
90
     */
91
    public function device()
92
    {
93
        return $this->belongsTo('App\Models\Device', 'device_id', 'device_id');
94
    }
95
96
}
97