Completed
Push — master ( 7d9761...77615c )
by Tony
02:53
created

Processor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormattedDescription() 0 18 1
A device() 0 4 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * App\Models\Processor
9
 *
10
 * @property integer $processor_id
11
 * @property integer $device_id
12
 * @property-read \App\Models\Device $device
13
 * @mixin \Eloquent
14
 * @property integer $entPhysicalIndex
15
 * @property integer $hrDeviceIndex
16
 * @property string $processor_oid
17
 * @property string $processor_index
18
 * @property string $processor_type
19
 * @property integer $processor_usage
20
 * @property string $processor_descr
21
 * @property integer $processor_precision
22
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereProcessorId($value)
23
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereEntPhysicalIndex($value)
24
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereHrDeviceIndex($value)
25
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereDeviceId($value)
26
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereProcessorOid($value)
27
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereProcessorIndex($value)
28
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereProcessorType($value)
29
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereProcessorUsage($value)
30
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereProcessorDescr($value)
31
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Processor whereProcessorPrecision($value)
32
 */
33
class Processor extends Model
34
{
35
    /**
36
     * Indicates if the model should be timestamped.
37
     *
38
     * @var bool
39
     */
40
    public $timestamps = false;
41
    /**
42
     * The table associated with the model.
43
     *
44
     * @var string
45
     */
46
    protected $table = 'processors';
47
    /**
48
     * The primary key column name.
49
     *
50
     * @var string
51
     */
52
    protected $primaryKey = 'processor_id';
53
54
    // ---- Helper Functions ----
55
56
    /**
57
     * Return Processor Description, formatted for display
58
     *
59
     * @return string
60
     */
61
    public function getFormattedDescription()
62
    {
63
        $bad_descr = array(
64
            'GenuineIntel:',
65
            'AuthenticAMD:',
66
            'Intel(R)',
67
            'CPU',
68
            '(R)',
69
            '(tm)',
70
        );
71
72
        $descr = str_replace($bad_descr, '', $this->processor_descr);
73
74
        // reduce extra spaces
75
        $descr = str_replace('  ', ' ', $descr);
76
77
        return $descr;
78
    }
79
80
    // ---- Query scopes ----
81
82
83
    // ---- Accessors/Mutators ----
84
85
86
    // ---- Define Relationships ----
87
88
    /**
89
     * Get the device this port belongs to.
90
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
91
     */
92
    public function device()
93
    {
94
        return $this->belongsTo('App\Models\Device', 'device_id', 'device_id');
95
    }
96
}
97