Test Failed
Push — develop ( 55b248...7d9761 )
by Tony
21:25
created

Processor::device()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
 */
15
class Processor extends Model
16
{
17
    /**
18
     * Indicates if the model should be timestamped.
19
     *
20
     * @var bool
21
     */
22
    public $timestamps = false;
23
    /**
24
     * The table associated with the model.
25
     *
26
     * @var string
27
     */
28
    protected $table = 'processors';
29
    /**
30
     * The primary key column name.
31
     *
32
     * @var string
33
     */
34
    protected $primaryKey = 'processor_id';
35
36
    // ---- Define Helper Functions ----
37
38
    /**
39
     * Return Processor Description, formatted for display
40
     *
41
     * @return string
42
     */
43
    public function getFormattedDescription()
44
    {
45
        $bad_descr = array(
46
            'GenuineIntel:',
47
            'AuthenticAMD:',
48
            'Intel(R)',
49
            'CPU',
50
            '(R)',
51
            '(tm)',
52
        );
53
54
        $descr = str_replace($bad_descr, '', $this->processor_descr);
0 ignored issues
show
Documentation introduced by
The property processor_descr does not exist on object<App\Models\Processor>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
55
56
        // reduce extra spaces
57
        $descr = str_replace('  ', ' ', $descr);
58
59
        return $descr;
60
    }
61
62
    // ---- Accessors/Mutators ----
63
64
65
    // ---- Query scopes ----
66
67
68
    // ---- Define Relationships ----
69
70
    /**
71
     * Get the device this port belongs to.
72
     *
73
     */
74
    public function device()
75
    {
76
        return $this->belongsTo('App\Models\Device', 'device_id', 'device_id');
77
    }
78
}
79
80