Failed Conditions
Push — develop ( 8574fc...cc7867 )
by Remco
04:15
created

Integration::get_config()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 18
nc 2
nop 1
dl 0
loc 25
ccs 0
cts 20
cp 0
crap 6
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Ingenico\OrderStandard;
4
5
use Pronamic\WordPress\Pay\Gateways\Ingenico\AbstractIntegration;
6
use Pronamic\WordPress\Pay\Gateways\Ingenico\Settings;
7
8
class Integration extends AbstractIntegration {
9
	public function __construct( $args = array() ) {
10
		$args = wp_parse_args( $args, array(
11
			'id'            => 'ogone-orderstandard',
12
			'name'          => 'Ingenico/Ogone - e-Commerce',
13
		) );
14
15
		parent::__construct( $args );
16
	}
17
18
	/**
19
	 * Get settings fields.
20
	 *
21
	 * @return array
22
	 */
23
	public function get_settings_fields() {
24
		return Settings::get_settings_fields( 'standard' );
25
	}
26
27
	public function get_config( $post_id ) {
28
		$mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
29
30
		$config = new Config();
31
32
		$form_action_url = get_post_meta( $post_id, '_pronamic_gateway_ogone_form_action_url', true );
33
34
		if ( '' !== $form_action_url ) {
35
			$config->set_form_action_url( $form_action_url );
0 ignored issues
show
Bug introduced by
It seems like $form_action_url can also be of type false; however, parameter $url of Pronamic\WordPress\Pay\G...::set_form_action_url() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
			$config->set_form_action_url( /** @scrutinizer ignore-type */ $form_action_url );
Loading history...
36
		}
37
38
		$config->mode                = $mode;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mode can also be of type false. However, the property $mode is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
39
		$config->psp_id              = get_post_meta( $post_id, '_pronamic_gateway_ogone_psp_id', true );
0 ignored issues
show
Documentation Bug introduced by
It seems like get_post_meta($post_id, ...ay_ogone_psp_id', true) can also be of type false. However, the property $psp_id is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
40
		$config->hash_algorithm      = get_post_meta( $post_id, '_pronamic_gateway_ogone_hash_algorithm', true );
0 ignored issues
show
Documentation Bug introduced by
It seems like get_post_meta($post_id, ..._hash_algorithm', true) can also be of type false. However, the property $hash_algorithm is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
41
		$config->sha_in_pass_phrase  = get_post_meta( $post_id, '_pronamic_gateway_ogone_sha_in_pass_phrase', true );
0 ignored issues
show
Documentation Bug introduced by
It seems like get_post_meta($post_id, ..._in_pass_phrase', true) can also be of type false. However, the property $sha_in_pass_phrase is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
42
		$config->sha_out_pass_phrase = get_post_meta( $post_id, '_pronamic_gateway_ogone_sha_out_pass_phrase', true );
0 ignored issues
show
Documentation Bug introduced by
It seems like get_post_meta($post_id, ...out_pass_phrase', true) can also be of type false. However, the property $sha_out_pass_phrase is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
43
		$config->user_id             = get_post_meta( $post_id, '_pronamic_gateway_ogone_user_id', true );
0 ignored issues
show
Documentation Bug introduced by
It seems like get_post_meta($post_id, ...y_ogone_user_id', true) can also be of type false. However, the property $user_id is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
44
		$config->password            = get_post_meta( $post_id, '_pronamic_gateway_ogone_password', true );
0 ignored issues
show
Documentation Bug introduced by
It seems like get_post_meta($post_id, ..._ogone_password', true) can also be of type false. However, the property $password is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
45
		$config->order_id            = get_post_meta( $post_id, '_pronamic_gateway_ogone_order_id', true );
0 ignored issues
show
Bug introduced by
The property order_id does not seem to exist on Pronamic\WordPress\Pay\G...co\OrderStandard\Config.
Loading history...
46
		$config->param_var           = get_post_meta( $post_id, '_pronamic_gateway_ogone_param_var', true );
0 ignored issues
show
Bug introduced by
The property param_var does not seem to exist on Pronamic\WordPress\Pay\G...co\OrderStandard\Config.
Loading history...
47
		$config->template_page       = get_post_meta( $post_id, '_pronamic_gateway_ogone_template_page', true );
0 ignored issues
show
Bug introduced by
The property template_page does not seem to exist on Pronamic\WordPress\Pay\G...co\OrderStandard\Config.
Loading history...
48
		$config->alias_enabled       = get_post_meta( $post_id, '_pronamic_gateway_ogone_alias_enabled', true );
0 ignored issues
show
Bug introduced by
The property alias_enabled does not seem to exist on Pronamic\WordPress\Pay\G...co\OrderStandard\Config.
Loading history...
49
		$config->alias_usage         = get_post_meta( $post_id, '_pronamic_gateway_ogone_alias_usage', true );
0 ignored issues
show
Bug introduced by
The property alias_usage does not seem to exist on Pronamic\WordPress\Pay\G...co\OrderStandard\Config.
Loading history...
50
51
		return $config;
52
	}
53
}
54