File transaction.class.php
has 383 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
class Transaction extends Base {
protected $table = 'transactions';
Function getTransactions
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getTransactions($start=0, $filter=NULL, $limit=30, $account_id=NULL) {
$this->debug->append("STA " . __METHOD__, 4);
$sql = "
SELECT
t.id AS id,
- 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 getTransactions
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTransactions($start=0, $filter=NULL, $limit=30, $account_id=NULL) {
$this->debug->append("STA " . __METHOD__, 4);
$sql = "
SELECT
t.id AS id,
Method getTransactionTypebyTime
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTransactionTypebyTime($account_id=NULL) {
$this->debug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
$stmt = $this->mysqli->prepare("
SELECT
Function getTransactionSummary
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getTransactionSummary($account_id=NULL) {
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
$sql = "
SELECT
SUM(t.amount) AS total, t.type AS type
- 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 createDebitRecord
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createDebitRecord($account_id, $coin_address, $amount, $type) {
// Calculate and deduct txfee from amount
$type == 'Debit_MP' ? $txfee = $this->config['txfee_manual'] : $txfee = $this->config['txfee_auto'];
$amount = $amount - $txfee;
// Add Debit record
Method getTransactionSummary
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTransactionSummary($account_id=NULL) {
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
$sql = "
SELECT
SUM(t.amount) AS total, t.type AS type
Method getMPQueue
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getMPQueue($limit=250) {
$stmt = $this->mysqli->prepare("
SELECT
a.id,
a.username,
Method getAPQueue
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAPQueue($limit=250) {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("
SELECT
a.id,
Consider simplifying this complex logical expression. Open
if (empty($filter['type']) || ($filter['type'] != 'Debit_AP' && $filter['type'] != 'Debit_MP' && $filter['type'] != 'TXFee' && $filter['type'] != 'Credit_PPS' && $filter['type'] != 'Fee_PPS' && $filter['type'] != 'Donation_PPS')) {
$aFilter[] = "( b.confirmations >= " . $this->config['confirmations'] . " OR ISNULL(b.confirmations) )";
}
Avoid deeply nested control flow statements. Open
if (empty($filter['type']) || ($filter['type'] != 'Debit_AP' && $filter['type'] != 'Debit_MP' && $filter['type'] != 'TXFee' && $filter['type'] != 'Credit_PPS' && $filter['type'] != 'Fee_PPS' && $filter['type'] != 'Donation_PPS')) {
$aFilter[] = "( b.confirmations >= " . $this->config['confirmations'] . " OR ISNULL(b.confirmations) )";
}
Function createDebitRecord
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function createDebitRecord($account_id, $coin_address, $amount, $type) {
// Calculate and deduct txfee from amount
$type == 'Debit_MP' ? $txfee = $this->config['txfee_manual'] : $txfee = $this->config['txfee_auto'];
$amount = $amount - $txfee;
// Add Debit record
- 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 addTransaction
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addTransaction($account_id, $amount, $type='Credit', $block_id=NULL, $coin_address=NULL, $txid=NULL) {
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $this->sqlError();
Avoid too many return
statements within this method. Open
return $transaction_id;