StoreProcessor::processRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 1
dl 0
loc 3
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\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