Failed Conditions
Push — develop ( 49fae7...1e38eb )
by Remco
04:39
created

CLI   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 33
ccs 0
cts 17
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A wp_cli_transaction_status() 0 7 2
1
<?php
2
/**
3
 * CLI
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2021 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Buckaroo
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Buckaroo;
12
13
/**
14
 * Title: CLI
15
 * Description:
16
 * Copyright: 2005-2021 Pronamic
17
 * Company: Pronamic
18
 *
19
 * @author  Remco Tolsma
20
 * @version 2.1.0
21
 * @since   2.1.0
22
 * @link    https://github.com/woocommerce/woocommerce/blob/3.9.0/includes/class-wc-cli.php
23
 */
24
class CLI {
25
	/**
26
	 * Construct CLI.
27
	 */
28
	public function __construct( $integration ) {
29
		$this->integration = $integration;
0 ignored issues
show
Bug Best Practice introduced by
The property integration does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30
31
		\WP_CLI::add_command(
0 ignored issues
show
Bug introduced by
The type WP_CLI was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
			'pronamic-pay buckaroo transaction status',
33
			function( $args, $assoc_args ) {
34
				$this->wp_cli_transaction_status( $args, $assoc_args );
35
			},
36
			array(
37
				'shortdesc' => 'This returns the status for the provided transaction',
38
			)
39
		);
40
	}
41
42
	/**
43
	 * CLI transaction status.
44
	 *
45
	 * @link https://testcheckout.buckaroo.nl/json/Docs/Api/GET-json-Transaction-Status-transactionKey
46
	 * @param array<string> $args       Arguments.
47
	 * @param array<string> $assoc_args Associative arguments.
48
	 * @return void
49
	 */
50
	public function wp_cli_transaction_status( $args, $assoc_args ) {
51
		$gateway = $this->integration->get_gateway( $assoc_args['config_id'] );
52
53
		foreach ( $args as $transaction_key ) {
54
			$result = $gateway->request( 'GET', 'Transaction/Status/' . $transaction_key );
55
56
			\WP_CLI::line( \wp_json_encode( $result, \JSON_PRETTY_PRINT ) );
57
		}
58
	}
59
}
60