PaymentDevelopmentAdmin::PaymentTypes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/**
4
 * Development tools for payments
5
 *
6
 * @package payment
7
 */
8
class PaymentDevelopmentAdmin extends Controller{
9
10
	public function index() {
0 ignored issues
show
Complexity introduced by
This operation has 3906251 execution paths which exceeds the configured maximum of 200.

A high number of execution paths generally suggests many nested conditional statements and make the code less readible. This can usually be fixed by splitting the method into several smaller methods.

You can also find more information in the “Code” section of your repository.

Loading history...
11
		$renderer = DebugView::create();
12
		$renderer->writeHeader();
13
		$renderer->writeInfo("Installed Omnipay Payment Gateways", Director::absoluteBaseURL());
14
		$types = $this->PaymentTypes();
15
16
		echo "<table style=\"font-size:12px;\" border=1 cellspacing=0>
17
				<thead>
18
					<tr>
19
						<td>Short Name</td>
20
						<td>Full name</td>
21
						<td>Purchase</td>
22
						<td>Authorize</td>
23
						<td>CompleteAuthorize</td>
24
						<td>Capture</td>
25
						<td>Complete Purchase</td>
26
						<td>Refund</td>
27
						<td>Void</td>
28
						<td>Create Card</td>
29
						<td>Delete Card</td>
30
						<td>Update Card</td>
31
					</tr>
32
				</thead>
33
			<tbody>";
34
35
		foreach ($types as $gateway) {
36
			echo "<tr>".
37
					"<td>".$gateway->getShortName()."</td>".
38
					"<td>".$gateway->getName()."</td>".
39
					"<td>yes</td>". //purchase is always supported
40
					"<td>".($gateway->supportsAuthorize() ? "yes" : "")."</td>".
41
					"<td>".($gateway->supportsCompleteAuthorize() ? "yes" : "")."</td>".
42
					"<td>".($gateway->supportsCapture() ? "yes" : "")."</td>".
43
					"<td>".($gateway->supportsCompletePurchase() ? "yes" : "")."</td>".
44
					"<td>".($gateway->supportsRefund() ? "yes" : "")."</td>".
45
					"<td>".($gateway->supportsVoid() ? "yes" : "")."</td>".
46
					"<td>".($gateway->supportsCreateCard() ? "yes" : "")."</td>".
47
					"<td>".($gateway->supportsDeleteCard() ? "yes" : "")."</td>".
48
					"<td>".($gateway->supportsUpdateCard() ? "yes" : "")."</td>".
49
			"</tr>";
50
			if ($this->request->getVar('defaults')) {
51
				echo "<tr><td colspan=\"11\">";
52
					var_dump($gateway->getDefaultParameters());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($gateway->getDefaultParameters()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
53
				echo "</td></tr>";
54
			}
55
		}
56
		echo "</tbody></table>";
57
		$renderer->writeFooter();
58
	}
59
60
	/**
61
	 * Get all available payment types
62
	 */
63
	private function PaymentTypes() {
64
		$gateways =  Omnipay\Common\GatewayFactory::find();
65
		$gateways = array_map(function($name) {
66
			$factory = new Omnipay\Common\GatewayFactory;
67
			return $factory->create($name);
68
		}, $gateways);
69
		return $gateways;
70
	}
71
72
}
73