WalletStore::purchase()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
nc 1
nop 2
dl 0
loc 5
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\ChargeableApi\Store;
6
7
use Damax\ChargeableApi\Identity\Identity;
8
use Damax\ChargeableApi\Product\Product;
9
use Damax\ChargeableApi\Wallet\WalletFactory;
10
11
final class WalletStore implements Store
12
{
13
    private $walletFactory;
14
15
    public function __construct(WalletFactory $walletFactory)
16
    {
17
        $this->walletFactory = $walletFactory;
18
    }
19
20
    public function purchase(Identity $identity, Product $product): Receipt
21
    {
22
        $this->walletFactory->create($identity)->withdraw($product->price());
23
24
        return new Receipt($identity, $product);
25
    }
26
}
27