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

SexAttribute   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSexAttribute() 0 4 1
A setSexAttribute() 0 4 1
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