PaymentConfigFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 15 2
1
<?php
2
3
/**
4
 * This file is part of the Pixidos package.
5
 *
6
 *  (c) Ondra Votava <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 *
11
 */
12
13
declare(strict_types=1);
14
15
namespace Pixidos\GPWebPay\Config\Factory;
16
17
use Pixidos\GPWebPay\Config\PaymentConfig;
18
use Pixidos\GPWebPay\Enum\DepositFlag as DepositFlagEnum;
19
use Pixidos\GPWebPay\Param\DepositFlag;
20
use Pixidos\GPWebPay\Param\MerchantNumber;
21
use Pixidos\GPWebPay\Param\ResponseUrl;
22
23
class PaymentConfigFactory
24
{
25
    /**
26
     * @param string $url
27
     * @param string $merchantNumber
28
     * @param int    $depositFlag
29
     * @param string $gateway
30
     * @param string $responseUrl
31
     * @return PaymentConfig
32
     */
33 8
    public function create(
34
        string $url,
35
        string $merchantNumber,
36
        int $depositFlag,
37
        string $gateway,
38
        string $responseUrl
39
    ): PaymentConfig {
40 8
        $target = '' !== $responseUrl ? new ResponseUrl($responseUrl) : null;
41
42 8
        return new PaymentConfig(
43 8
            $url,
44 8
            new MerchantNumber($merchantNumber),
45 8
            new DepositFlag(DepositFlagEnum::fromScalar($depositFlag)),
46 8
            $gateway,
47 8
            $target
48 8
        );
49
    }
50
}
51