Completed
Push — master ( daed8a...c138e4 )
by Jorge
01:27
created

Tax   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A taxGroup() 0 4 1
A info() 0 6 1
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
    public function taxGroup()
15
    {
16
        return $this->belongsTo(TaxGroup::class);
17
    }
18
19
    public function info(): TaxContract
20
    {
21
        $className = '\\FeiMx\\Tax\\Taxes\\'.strtoupper($this->name);
22
23
        return new $className($this->retention);
24
    }
25
26
    public function getInfoAttribute(): TaxContract
27
    {
28
        return $this->info();
29
    }
30
31
    public function scopeRetention($query)
32
    {
33
        return $query->whereRetention(true)->orWhere('name', 'isr');
34
    }
35
36
    public function scopeTraslate($query)
37
    {
38
        return $query->whereRetention(false)->where('name', '<>', 'isr');
39
    }
40
}
41