MPOS/php-mpos

View on GitHub
include/classes/notification.class.php

Summary

Maintainability
C
1 day
Test Coverage

Function getNotificationSettings has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  public function getNotificationSettings($account_id) {
    // Some defaults, we cover them here so we can avoid adding default settings on user creation
    $aDefaults = array( 'newsletter' => 1 );
    $this->debug->append("STA " . __METHOD__, 4);
    $stmt = $this->mysqli->prepare("SELECT * FROM $this->tableSettings WHERE account_id = ?");
Severity: Minor
Found in include/classes/notification.class.php - About 3 hrs to fix

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 sendNotification has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  public function sendNotification($account_id, $strType, $aMailData) {
    // Check if we notified for this event already
    if ( $this->isNotified($aMailData) ) {
      $this->setErrorMessage('A notification for this event has been sent already');
      return false;
Severity: Minor
Found in include/classes/notification.class.php - About 2 hrs to fix

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 sendNotification has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public function sendNotification($account_id, $strType, $aMailData) {
    // Check if we notified for this event already
    if ( $this->isNotified($aMailData) ) {
      $this->setErrorMessage('A notification for this event has been sent already');
      return false;
Severity: Minor
Found in include/classes/notification.class.php - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

        return false;
    Severity: Major
    Found in include/classes/notification.class.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return true;
      Severity: Major
      Found in include/classes/notification.class.php - About 30 mins to fix

        Function updateSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          public function updateSettings($account_id, $data) {
            $this->debug->append("STA " . __METHOD__, 4);
            $failed = $ok = 0;
            foreach ($data as $type => $active) {
              $stmt = $this->mysqli->prepare("INSERT INTO $this->tableSettings (active, type, account_id) VALUES (?,?,?) ON DUPLICATE KEY UPDATE active = ?");
        Severity: Minor
        Found in include/classes/notification.class.php - About 25 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status