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

ModePostEmail   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOwnerAttribute() 0 6 2
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