Tax   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 6
c 2
b 0
f 2
lcom 0
cbo 1
dl 0
loc 37
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A taxGroup() 0 4 1
A info() 0 6 2
A getInfoAttribute() 0 4 1
A scopeRetention() 0 4 1
A scopeTraslate() 0 4 1
1
<?php
2
3
namespace FeiMx\Tax\Models;
4
5
use FeiMx\Tax\Contracts\TaxContract;
6
use Illuminate\Database\Eloquent\Model;
7
8
class Tax extends Model
9
{
10
    protected $fillable = [
11
        'name', 'type', 'retention',
12
    ];
13
14
    protected $casts = [
15
        'retention' => 'boolean',
16
    ];
17
18
    public function taxGroup()
19
    {
20
        return $this->belongsTo(TaxGroup::class);
21
    }
22
23
    public function info(): TaxContract
24
    {
25
        $className = '\\FeiMx\\Tax\\Taxes\\'.strtoupper($this->name);
26
27
        return new $className($this->retention ? $this->retention : $this->type);
28
    }
29
30
    public function getInfoAttribute(): TaxContract
31
    {
32
        return $this->info();
33
    }
34
35
    public function scopeRetention($query)
36
    {
37
        return $query->whereRetention(true);
38
    }
39
40
    public function scopeTraslate($query)
41
    {
42
        return $query->whereRetention(false);
43
    }
44
}
45