Refund::amount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Siak\Tontine\Model;
4
5
use Illuminate\Database\Eloquent\Casts\Attribute;
6
use Siak\Tontine\Service\Meeting\Credit\DebtCalculator;
7
8
use function app;
9
10
class Refund extends Base
11
{
12
    /**
13
     * Indicates if the model should be timestamped.
14
     *
15
     * @var bool
16
     */
17
    public $timestamps = false;
18
19
    public function session()
20
    {
21
        return $this->belongsTo(Session::class);
22
    }
23
24
    public function debt()
25
    {
26
        return $this->belongsTo(Debt::class);
27
    }
28
29
    /**
30
     * @return Attribute
31
     */
32
    protected function amount(): Attribute
33
    {
34
        return Attribute::make(
35
            get: fn() => app()->make(DebtCalculator::class)
36
                ->getDebtDueAmount($this->debt, $this->session, false),
37
        );
38
    }
39
}
40