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

WalletService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 17
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A fee() 0 7 2
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