File DonationData.php
has 723 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
use SmashPig\Core\DataStores\QueueWrapper;
use SmashPig\Core\SequenceGenerators;
use SmashPig\PaymentData\ReferenceData\CurrencyRates;
use SmashPig\PaymentData\ReferenceData\NationalCurrencies;
DonationData
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
class DonationData implements LogPrefixProvider {
/** @var array */
protected $normalized = [];
/** @var array */
protected $dataSources = [];
Function setCountry
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function setCountry() {
$regen = true;
$country = '';
if ( $this->isSomething( '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 getCleanTrackingData
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCleanTrackingData( $unset = false ) {
// define valid tracking fields
$tracking_fields = [
'amount',
'appeal',
Method getMessageFields
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getMessageFields() {
return [
'contribution_tracking_id',
'anonymous',
'utm_source',
Function getCleanTrackingData
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getCleanTrackingData( $unset = false ) {
// define valid tracking fields
$tracking_fields = [
'amount',
'appeal',
- 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 setUtmSource
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setUtmSource() {
$utm_source = $this->getVal( 'utm_source' );
$utm_source_id = $this->getVal( 'utm_source_id' );
if ( $this->getVal( 'payment_method' ) ) {
Method setNormalizedAmount
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setNormalizedAmount() {
if ( $this->getVal( 'amount' ) === 'Other' ) {
$this->setVal( 'amount', $this->getVal( 'amountGiven' ) );
}
Function setUtmSource
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function setUtmSource() {
$utm_source = $this->getVal( 'utm_source' );
$utm_source_id = $this->getVal( 'utm_source_id' );
if ( $this->getVal( 'payment_method' ) ) {
- 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 setCountry
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setCountry() {
$regen = true;
$country = '';
if ( $this->isSomething( 'country' ) ) {
Method normalize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function normalize() {
// FIXME: there's a ghost invocation during DonationData construction.
// This condition should actually be "did data come from anywhere?"
if ( $this->normalized ) {
// Cast all values to string.
Function setNormalizedAmount
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function setNormalizedAmount() {
if ( $this->getVal( 'amount' ) === 'Other' ) {
$this->setVal( 'amount', $this->getVal( 'amountGiven' ) );
}
- 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 integrateDataFromSession
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function integrateDataFromSession() {
/**
* if the thing coming in from the session isn't already something,
* replace it.
* if it is: assume that the session data was meant to be replaced
- 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 populateData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function populateData( $external_data = false ) {
$this->normalized = [];
if ( is_array( $external_data ) ) {
// I don't care if you're a test or not. At all.
$this->normalized = $external_data;
- 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 setNormalizedRecurring
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function setNormalizedRecurring() {
if ( $this->isSomething( 'recurring_paypal' ) && ( $this->getVal( 'recurring_paypal' ) === '1' || $this->getVal( 'recurring_paypal' ) === 'true' ) ) {
$this->setVal( 'recurring', true );
$this->expunge( 'recurring_paypal' );
}
- 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 addData
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addData( $newdata, $source = 'internal' ) {
if ( is_array( $newdata ) ) {
foreach ( $newdata as $key => $val ) {
if ( !is_array( $val ) ) {
$this->setVal( $key, $val );
- 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 normalize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function normalize() {
// FIXME: there's a ghost invocation during DonationData construction.
// This condition should actually be "did data come from anywhere?"
if ( $this->normalized ) {
// Cast all values to string.
- 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 setReferrer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function setReferrer() {
if ( !$this->isSomething( 'referrer' ) ) {
// Remove protocol and query strings to avoid tripping modsecurity
// TODO it would be a lot more privacy respecting to omit path too.
$referrer = '';
- 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"