Function chooseGatewayByPriority
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
public function chooseGatewayByPriority( $supportedGateways, $params ) {
$rules = $this->getConfig()->get( 'DonationInterfaceGatewayPriorityRules' );
foreach ( $rules as $rule ) {
// Do our $params match all the conditions for this rule?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getSupportedGateways
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
private function getSupportedGateways(
string $country,
?string $currency,
string $paymentMethod,
?string $paymentSubmethod,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method chooseGatewayByPriority
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function chooseGatewayByPriority( $supportedGateways, $params ) {
$rules = $this->getConfig()->get( 'DonationInterfaceGatewayPriorityRules' );
foreach ( $rules as $rule ) {
// Do our $params match all the conditions for this rule?
File GatewayChooser.php
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* GatewayChooser acts as a gateway-agnostic landing page.
* When passed a country, currency, and payment method combination, it determines the
Method getSupportedGateways
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getSupportedGateways(
string $country,
?string $currency,
string $paymentMethod,
?string $paymentSubmethod,
Method getParamsFromURL
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getParamsFromURL(): array {
// Get country code from request param, or, if it's not sent or is invalid, use
// geoip lookup
$country = $this->sanitizedValOrNull( 'country' );
Function getParamsFromURL
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function getParamsFromURL(): array {
// Get country code from request param, or, if it's not sent or is invalid, use
// geoip lookup
$country = $this->sanitizedValOrNull( 'country' );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method execute
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $par ) {
// Bow out if gateway chooser is not enabled
if ( !$this->getConfig()->get( 'DonationInterfaceEnableGatewayChooser' ) ) {
throw new BadTitleError();
}
Function execute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $par ) {
// Bow out if gateway chooser is not enabled
if ( !$this->getConfig()->get( 'DonationInterfaceEnableGatewayChooser' ) ) {
throw new BadTitleError();
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getSupportedGateways
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
string $country,
?string $currency,
string $paymentMethod,
?string $paymentSubmethod,
bool $recurring,