WalletStore   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 14
c 0
b 0
f 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A purchase() 0 5 1
A __construct() 0 3 1
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