Completed
Pull Request — master (#40)
by Бабичев
04:18
created

WalletService::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 2
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 Bavix\Wallet\Services;
4
5
use Bavix\Wallet\Interfaces\Taxing;
6
use Bavix\Wallet\Interfaces\Wallet;
7
8
class WalletService
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 16
    public function fee(Wallet $wallet, int $amount): int
19
    {
20 16
        if ($wallet instanceof Taxing) {
21 1
            return (int)($amount * $wallet->getFeePercent() / 100);
22
        }
23
24 16
        return 0;
25
    }
26
27
}
28