Completed
Pull Request — master (#14)
by Бабичев
03:24
created

Tax::fee()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

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