File Mustache.php
has 438 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
use LightnCandy\LightnCandy;
use MediaWiki\Extension\CLDR\CountryNames;
use MediaWiki\MediaWikiServices;
Function addFormFields
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
protected function addFormFields( &$data ) {
// If any of these are required, show the address block
$address_fields = [
'city',
'state_province',
- 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 addSubmethods
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function addSubmethods( &$data ) {
if ( !$this->gatewayPage->showSubmethodButtons() ) {
$data['show_submethods'] = false;
return;
}
- 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 addFormFields
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFormFields( &$data ) {
// If any of these are required, show the address block
$address_fields = [
'city',
'state_province',
Method addSubmethods
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addSubmethods( &$data ) {
if ( !$this->gatewayPage->showSubmethodButtons() ) {
$data['show_submethods'] = false;
return;
}
Function getErrors
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function getErrors() {
$errors = $this->gateway->getErrorState()->getErrors();
$return = [ 'errors' => [
'general' => [],
'field' => [],
- 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 getErrors
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getErrors() {
$errors = $this->gateway->getErrorState()->getErrors();
$return = [ 'errors' => [
'general' => [],
'field' => [],
Method getData
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getData() {
$data = $this->gateway->getData_Unstaged_Escaped();
$output = $this->gatewayPage->getContext()->getOutput();
$data['script_path'] = $this->scriptPath;
Method handleOptIn
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handleOptIn( &$data ) {
// Since this value can be 1, 0, or unset, we need to make
// special conditionals for the mustache logic
if ( !isset( $data['opt_in'] ) || $data['opt_in'] === '' ) {
return;
Function handleOptIn
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function handleOptIn( &$data ) {
// Since this value can be 1, 0, or unset, we need to make
// special conditionals for the mustache logic
if ( !isset( $data['opt_in'] ) || $data['opt_in'] === '' ) {
return;
- 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 getPartials
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getPartials( array $data ) {
$partials = [];
if ( empty( $data['variant'] ) ) {
$variantDir = false;
} else {
- 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 setAmountLabelKey
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function setAmountLabelKey( &$data ): void {
if ( $data['recurring'] ) {
$isAnnual = ( isset( $data['frequency_unit'] ) && $data['frequency_unit'] == 'year' );
if ( $isAnnual ) {
$key = 'donate_interface-annual-amount';
- 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"