Payment_Adaptive_Chained   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 51
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fields() 0 12 3
A _set_payment_type() 0 22 5
1
<?php
2
3
namespace OpenBuildings\PayPal;
4
5
/**
6
 * @author Haralan Dobrev <[email protected]>
7
 * @copyright 2013 OpenBuildings, Inc.
8
 * @license http://spdx.org/licenses/BSD-3-Clause
9
 */
10
class Payment_Adaptive_Chained extends Payment_Adaptive_Parallel {
11
12
	protected static $_allowed_action_types = array(
13
		self::ACTION_TYPE_PAY,
14
		self::ACTION_TYPE_CREATE,
15
		self::ACTION_TYPE_PAY_PRIMARY,
16
	);
17
18
	protected static $_allowed_fees_payer_types = array(
19
		self::FEES_PAYER_SENDER,
20
		self::FEES_PAYER_PRIMARYRECEIVER,
21
		self::FEES_PAYER_EACHRECEIVER,
22
		self::FEES_PAYER_SECONDARYONLY
23
	);
24
25
	public function fields()
26
	{
27
		$fields = parent::fields();
28
		$order = $this->order();
0 ignored issues
show
Unused Code introduced by
$order is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
30
		if ($this->config('pay_only_primary') AND $this->action_type() == 'PAY')
31
		{
32
			$fields['actionType'] = 'PAY_PRIMARY';
33
		}
34
35
		return $fields;
36
	}
37
38
	protected function _set_payment_type(array $fields)
39
	{
40
		$fields = parent::_set_payment_type($fields);
41
42
		$order = $this->order();
43
		$payment_type = $this->config('payment_type');
44
45
		if (isset($payment_type['primary'])
46
		 AND ($payment_type = $payment_type['primary']))
47
		{
48
			foreach ($order['receivers'] as $index => $receiver)
49
			{
50
				if ($receiver['primary'])
51
				{
52
					$fields['receiverList'][$index]['paymentType'] = $payment_type;
53
					break;
54
				}
55
			}
56
		}
57
58
		return $fields;
59
	}
60
}
61