Passed
Push — master ( 38cc9b...2ce834 )
by Moecasts
03:22
created

Tax::fee()   A

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 0
Metric Value
cc 2
eloc 3
nc 2
nop 3
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Moecasts\Laravel\Wallet;
4
5
use Moecasts\Laravel\Wallet\Interfaces\Taxing;
6
use Moecasts\Laravel\Wallet\Interfaces\Transferable;
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 10
    public static function fee(Transferable $transferable, Wallet $wallet,float $amount): float
20
    {
21 10
        if ($transferable instanceof Taxing) {
22 1
            return (float) ($amount * $wallet->coefficient($wallet->currency) * $transferable->getFeePercent() / 100);
23
        }
24
25 9
        return 0;
26
    }
27
28
}
29