Tax::fee()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 7
rs 10
ccs 4
cts 4
cp 1
crap 2
1
<?php
2
3
namespace Moecasts\Laravel\Wallet;
4
5
use Moecasts\Laravel\Wallet\Interfaces\Taxing;
6
use Moecasts\Laravel\Wallet\Interfaces\Assemblable;
7
use Moecasts\Laravel\Wallet\Models\Wallet;
8
9
class Tax
10
{
11
12
    /**
13
     * Consider the fee that the system will receive.
14
     *
15
     * @param Wallet $wallet
16
     * @param float $amount
17
     * @return float
18
     */
19 13
    public static function fee(Assemblable $assemblable, Wallet $wallet,float $amount): float
20
    {
21 13
        if ($assemblable instanceof Taxing) {
22 3
            return (float) ($amount * $wallet->coefficient($wallet->currency) * $assemblable->getFeePercent() / 100);
23
        }
24
25 10
        return 0;
26
    }
27
28
}
29