Passed
Pull Request — master (#94)
by
unknown
07:43
created

ApiKeysTestResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromRequest() 0 8 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * You can find more information about us on https://bitbag.io and write us
7
 * an email on [email protected].
8
 */
9
10
declare(strict_types=1);
11
12
namespace BitBag\SyliusMolliePlugin\Resolver;
13
14
use BitBag\SyliusMolliePlugin\Creator\ApiKeysTestCreatorInterface;
15
use BitBag\SyliusMolliePlugin\Form\Type\MollieGatewayConfigurationType;
16
use Symfony\Component\HttpFoundation\Request;
17
18
final class ApiKeysTestResolver implements ApiKeysTestResolverInterface
19
{
20
    /** @var ApiKeysTestCreatorInterface */
21
    private $apiKeysTestCreator;
22
23
    public function __construct(
24
        ApiKeysTestCreatorInterface $apiKeysTestCreator
25
    ) {
26
        $this->apiKeysTestCreator = $apiKeysTestCreator;
27
    }
28
29
    public function fromRequest(Request $request): array
30
    {
31
        $testApiKey = $request->get(MollieGatewayConfigurationType::API_KEY_TEST);
32
        $liveApiKey = $request->get(MollieGatewayConfigurationType::API_KEY_LIVE);
33
34
        return [
35
            $this->apiKeysTestCreator->create(MollieGatewayConfigurationType::API_KEY_TEST, $testApiKey),
36
            $this->apiKeysTestCreator->create(MollieGatewayConfigurationType::API_KEY_LIVE, $liveApiKey),
37
        ];
38
    }
39
}
40