Failed Conditions
Push — feature/webhook-status ( c2cf79 )
by Reüel
05:45
created

ConfigFactory::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 2
nc 4
nop 2
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\IDealBasic;
4
5
use Pronamic\WordPress\Pay\Core\GatewayConfigFactory;
6
7
/**
8
 * Title: Config factory
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.0
15
 * @since   1.0.0
16
 */
17
class ConfigFactory extends GatewayConfigFactory {
18
	private $config_class;
19
20
	public function __construct( $config_class = null, $config_test_class = null ) {
21
		$this->config_class      = is_null( $config_class ) ? __NAMESPACE__ . '\Config' : $config_class;
22
		$this->config_test_class = is_null( $config_test_class ) ? __NAMESPACE__ . '\Config' : $config_test_class;
0 ignored issues
show
Bug Best Practice introduced by
The property config_test_class does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
	}
24
25
	public function get_config( $post_id ) {
26
		$mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
27
28
		$config_class = ( Gateway::MODE_TEST === $mode ) ? $this->config_test_class : $this->config_class;
29
30
		$config = new $config_class();
31
32
		$config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_merchant_id', true );
33
		$config->sub_id      = get_post_meta( $post_id, '_pronamic_gateway_ideal_sub_id', true );
34
		$config->hash_key    = get_post_meta( $post_id, '_pronamic_gateway_ideal_hash_key', true );
35
		$config->purchase_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_purchase_id', true );
36
37
		return $config;
38
	}
39
}
40