Completed
Push — master ( 5d8274...535412 )
by Elf
03:21
created

DeviceModelAttribute::getDeviceModelAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace ElfSundae\Laravel\Support\Traits;
4
5
use ElfSundae\Laravel\Support\Helper;
6
7
trait DeviceModelAttribute
8
{
9
    /**
10
     * Get the `device_model` attribute.
11
     *
12
     * @return string|null
13
     */
14
    public function getDeviceModelAttribute()
15
    {
16
        $platform = property_exists($this, 'deviceModelKey') ? $this->deviceModelKey : 'platform';
1 ignored issue
show
Bug introduced by
The property deviceModelKey does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
18
        return Helper::iDeviceModel($this->{$platform});
19
    }
20
}
21