Passed
Branch master (ae98e8)
by Chubarov
04:40
created

ModePostEmail::getOwnerAttribute()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75
cc 2
eloc 3
nc 1
nop 1
crap 2.0625
1
<?php
2
3
namespace agoalofalife\postman\Models;
4
5
use agoalofalife\postman\Contract\Mode;
6
use Illuminate\Database\Eloquent\Model;
7
8
class ModePostEmail extends Model
9
{
10
    protected $fillable = ['name', 'description', 'owner'];
11
12 3
    public function getOwnerAttribute(string $value) : Mode
13
    {
14 3
        if (is_subclass_of($value, Mode::class) === false) {
15
            throw new \Exception('Class mode not implementation Mode contract.');
16
        }
17 3
        return new $value;
0 ignored issues
show
Bug Best Practice introduced by
The expression return new $value() returns the type object which includes types incompatible with the type-hinted return agoalofalife\postman\Contract\Mode.
Loading history...
18
    }
19
}
20