Completed
Push — master ( e68c06...8ce3f9 )
by Adolfo
14s queued 11s
created

PlanFeature   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A plan() 0 4 1
A isConsumable() 0 4 1
A getValue() 0 4 1
A make() 0 11 1
1
<?php
2
3
namespace Sagitarius29\LaravelSubscriptions\Entities;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Sagitarius29\LaravelSubscriptions\Contracts\PlanFeatureContract;
7
8
class PlanFeature extends Model implements PlanFeatureContract
9
{
10
    protected $table = 'plan_features';
11
12
    protected $fillable = [
13
        'code', 'value', 'sort_order', 'is_consumable',
14
    ];
15
16
    public function plan()
17
    {
18
        return $this->belongsTo(config('subscription.entities.plan'));
19
    }
20
21
    public function isConsumable(): bool
22
    {
23
        return $this->is_consumable;
24
    }
25
26
    public function getValue(): int
27
    {
28
        return $this->value;
29
    }
30
31
    public static function make(string $code, int $value, int $sortOrder, bool $isConsumable = false): Model
32
    {
33
        $attributes = [
34
            'code'          => $code,
35
            'value'         => $value,
36
            'sort_order'    => $sortOrder,
37
            'is_consumable' => $isConsumable,
38
        ];
39
40
        return new self($attributes);
41
    }
42
}
43