| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 99 | 
| Code Lines | 62 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 35 | 	public function test_init() { | 
            ||
| 36 | // Actions  | 
            ||
| 37 | //add_action( 'http_api_debug', array( $this, 'http_api_debug' ), 10, 5 );  | 
            ||
| 38 | add_filter( 'pre_http_request', array( $this, 'pre_http_request' ), 10, 3 );  | 
            ||
| 39 | |||
| 40 | // Config  | 
            ||
| 41 | $config = new Config();  | 
            ||
| 42 | |||
| 43 | $config->mode = getenv( 'MULTISAFEPAY_MODE' );  | 
            ||
| 44 | $config->account_id = getenv( 'MULTISAFEPAY_ACCOUNT_ID' );  | 
            ||
| 45 | $config->site_id = getenv( 'MULTISAFEPAY_SITE_ID' );  | 
            ||
| 46 | $config->site_code = getenv( 'MULTISAFEPAY_SECURE_CODE' );  | 
            ||
| 47 | |||
| 48 | 		if ( Gateway::MODE_TEST === $config->mode ) { | 
            ||
| 49 | $config->api_url = MultiSafepay::API_TEST_URL;  | 
            ||
| 50 | 		} else { | 
            ||
| 51 | $config->api_url = MultiSafepay::API_PRODUCTION_URL;  | 
            ||
| 52 | }  | 
            ||
| 53 | |||
| 54 | // Client  | 
            ||
| 55 | $client = new Client();  | 
            ||
| 56 | |||
| 57 | $client->api_url = $config->api_url;  | 
            ||
| 58 | |||
| 59 | // Message  | 
            ||
| 60 | $merchant = new Merchant();  | 
            ||
| 61 | |||
| 62 | $merchant->account = $config->account_id;  | 
            ||
| 63 | $merchant->site_id = $config->site_id;  | 
            ||
| 64 | $merchant->site_secure_code = $config->site_code;  | 
            ||
| 65 | $merchant->notification_url = home_url();  | 
            ||
| 66 | $merchant->redirect_url = home_url();  | 
            ||
| 67 | $merchant->cancel_url = home_url();  | 
            ||
| 68 | $merchant->close_window = 'false';  | 
            ||
| 69 | |||
| 70 | $customer = new Customer();  | 
            ||
| 71 | |||
| 72 | $customer->locale = get_locale();  | 
            ||
| 73 | $customer->ip_address = Server::get( 'REMOTE_ADDR', FILTER_VALIDATE_IP );  | 
            ||
| 74 | $customer->forwarded_ip = Server::get( 'HTTP_X_FORWARDED_FOR', FILTER_VALIDATE_IP );  | 
            ||
| 75 | $customer->first_name = '';  | 
            ||
| 76 | $customer->last_name = '';  | 
            ||
| 77 | $customer->address_1 = 'Test';  | 
            ||
| 78 | $customer->address_2 = '';  | 
            ||
| 79 | $customer->house_number = '1';  | 
            ||
| 80 | $customer->zip_code = '1234 AB';  | 
            ||
| 81 | $customer->city = 'Test';  | 
            ||
| 82 | $customer->country = 'Test';  | 
            ||
| 83 | $customer->phone = '';  | 
            ||
| 84 | $customer->email = get_option( 'admin_email' );  | 
            ||
| 85 | |||
| 86 | $transaction = new Transaction();  | 
            ||
| 87 | |||
| 88 | $transaction->id = uniqid();  | 
            ||
| 89 | $transaction->currency = 'EUR';  | 
            ||
| 90 | $transaction->amount = 123;  | 
            ||
| 91 | $transaction->description = 'Test';  | 
            ||
| 92 | $transaction->var1 = '';  | 
            ||
| 93 | $transaction->var2 = '';  | 
            ||
| 94 | $transaction->var3 = '';  | 
            ||
| 95 | $transaction->items = '';  | 
            ||
| 96 | $transaction->manual = 'false';  | 
            ||
| 97 | $transaction->gateway = '';  | 
            ||
| 98 | $transaction->days_active = '';  | 
            ||
| 99 | $transaction->gateway = Methods::IDEAL;  | 
            ||
| 100 | //$transaction->gateway = Pronamic\WordPress\Pay\Gateways\MultiSafepay\Gateways::MASTERCARD;  | 
            ||
| 101 | //$transaction->gateway = Pronamic\WordPress\Pay\Gateways\MultiSafepay\Gateways::BANK_TRANSFER;  | 
            ||
| 102 | |||
| 103 | //$gateway_info = null;  | 
            ||
| 104 | $gateway_info = new GatewayInfo();  | 
            ||
| 105 | |||
| 106 | $gateway_info->issuer_id = '3151';  | 
            ||
| 107 | |||
| 108 | $message = new XML\DirectTransactionRequestMessage( $merchant, $customer, $transaction, $gateway_info );  | 
            ||
| 109 | |||
| 110 | $signature = Signature::generate( $transaction->amount, $transaction->currency, $merchant->account, $merchant->site_id, $transaction->id );  | 
            ||
| 111 | |||
| 112 | $message->signature = $signature;  | 
            ||
| 113 | |||
| 114 | // Response  | 
            ||
| 115 | $response = $client->start_transaction( $message );  | 
            ||
| 116 | |||
| 117 | // Expected  | 
            ||
| 118 | $expected = new XML\DirectTransactionResponseMessage();  | 
            ||
| 119 | |||
| 120 | $expected->result = 'ok';  | 
            ||
| 121 | |||
| 122 | $expected->transaction = new Transaction();  | 
            ||
| 123 | |||
| 124 | $expected->transaction->id = '554202bb33498';  | 
            ||
| 125 | |||
| 126 | $expected->gateway_info = new GatewayInfo();  | 
            ||
| 127 | |||
| 128 | $expected->gateway_info->issuer_id = '3151';  | 
            ||
| 129 | $expected->gateway_info->redirect_url = 'http://testpay.multisafepay.com/simulator/ideal?trxid=10447735643871196&ideal=prob&issuerid=3151&merchantReturnURL=https%3A%2F%2Ftestpay%2Emultisafepay%2Ecom%2Fdirect%2Fcomplete%2F%3Fid%3D9943038943576689';  | 
            ||
| 130 | $expected->gateway_info->ext_var = 'https://testpay.multisafepay.com/direct/complete/';  | 
            ||
| 131 | |||
| 132 | // Assert  | 
            ||
| 133 | $this->assertEquals( $expected, $response );  | 
            ||
| 134 | }  | 
            ||
| 136 | 
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.