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

SexAttribute::setSexAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ElfSundae\Laravel\Support\Traits;
4
5
use ElfSundae\Laravel\Support\Constants\Sex;
6
7
trait SexAttribute
8
{
9
    /**
10
     * Get the 'sex' attribute.
11
     *
12
     * @param  int  $value
13
     * @return string|null
14
     */
15
    public function getSexAttribute($value)
16
    {
17
        return Sex::string($value);
18
    }
19
20
    /**
21
     * Set the 'sex' attribute.
22
     *
23
     * @param  mixed  $value
24
     */
25
    public function setSexAttribute($value)
26
    {
27
        $this->attributes['sex'] = Sex::type($value);
1 ignored issue
show
Bug introduced by
The property attributes 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...
28
    }
29
}
30