Completed
Pull Request — master (#1)
by Dmitry
03:17
created

OmnipayFactory::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 1
cts 1
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
3
namespace hiqdev\php\merchant\factories;
4
5
use Omnipay\Common\GatewayInterface;
6
use Omnipay\Common\Helper;
7
8
/**
9
 * Class OmnipayFactory
10
 *
11
 * @author Dmytro Naumenko <[email protected]>
12
 */
13
class OmnipayFactory implements GatewayFactoryInterface
14
{
15
    public function build(string $type, $parameters): GatewayInterface
16
    {
17
        $className = Helper::getGatewayClassName($type);
18
        /** @var GatewayInterface $gateway */
19
        $gateway = new $className();
20
        $gateway->initialize($parameters);
21
22
        return $gateway;
23 2
    }
24
}
25