StoreProcessor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 20
c 0
b 0
f 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A processRequest() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\ChargeableApi\Store;
6
7
use Damax\ChargeableApi\Identity\IdentityFactory;
8
use Damax\ChargeableApi\InsufficientFunds;
9
use Damax\ChargeableApi\Processor;
10
use Damax\ChargeableApi\Product\ProductResolutionFailed;
11
use Damax\ChargeableApi\Product\Resolver;
12
13
final class StoreProcessor implements Processor
14
{
15
    private $store;
16
    private $identityFactory;
17
    private $productResolver;
18
19
    public function __construct(Store $store, IdentityFactory $identityFactory, Resolver $productResolver)
20
    {
21
        $this->store = $store;
22
        $this->identityFactory = $identityFactory;
23
        $this->productResolver = $productResolver;
24
    }
25
26
    /**
27
     * @throws ProductResolutionFailed
28
     * @throws InsufficientFunds
29
     */
30
    public function processRequest($request): void
31
    {
32
        $this->store->purchase($this->identityFactory->create(), $this->productResolver->resolve($request));
33
    }
34
}
35