railpage/railpagecore

View on GitHub
lib/Reminders/Reminder.php

Summary

Maintainability
D
1 day
Test Coverage

Function send has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

        public function send($markAsSent = false) {
            
            $this->validate(); 
            
            $Smarty = AppCore::getSmarty(); 
Severity: Minor
Found in lib/Reminders/Reminder.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 send has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function send($markAsSent = false) {
            
            $this->validate(); 
            
            $Smarty = AppCore::getSmarty(); 
Severity: Major
Found in lib/Reminders/Reminder.php - About 2 hrs to fix

    Function setReminderDate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            public function setReminderDate(DateTime $Reminder, DateTime $EventDate) {
                
                $Now = new DateTime;
                
                if ($EventDate <= $Now) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php - About 1 hr 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 exists has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            public function exists() {
                
                if (!$this->User instanceof User) {
                    throw new Exception("Can't lookup a reminder because no user was specified");
                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php - About 35 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

    The method send() has 114 lines of code. Current threshold is set to 100. Avoid really long methods.
    Open

            public function send($markAsSent = false) {
                
                $this->validate(); 
                
                $Smarty = AppCore::getSmarty(); 
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    The method send() has an NPath complexity of 392. The configured NPath complexity threshold is 200.
    Open

            public function send($markAsSent = false) {
                
                $this->validate(); 
                
                $Smarty = AppCore::getSmarty(); 
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    The method send() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
    Open

            public function send($markAsSent = false) {
                
                $this->validate(); 
                
                $Smarty = AppCore::getSmarty(); 
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

    The method send has a boolean flag argument $markAsSent, which is a certain sign of a Single Responsibility Principle violation.
    Open

            public function send($markAsSent = false) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method __construct has a boolean flag argument $id, which is a certain sign of a Single Responsibility Principle violation.
    Open

            public function __construct($id = false) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method commit uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    if (!$this->exists()) {
                        $this->db->insert("reminders", $data);
                        $this->id = $this->db->lastInsertId();
                    }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    Avoid assigning values to variables in if clauses and the like (line '153', column '21').
    Open

            public function __construct($id = false) {
                
                parent::__construct(); 
                
                $this->ThisModule = new Module("reminders");
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    The method exists uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    return false;
                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    Avoid assigning values to variables in if clauses and the like (line '325', column '25').
    Open

            public function send($markAsSent = false) {
                
                $this->validate(); 
                
                $Smarty = AppCore::getSmarty(); 
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    Avoid using empty try-catch blocks in send.
    Open

                } catch (Exception $e) {
                    
                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    EmptyCatchBlock

    Since: 2.7.0

    Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

    Example

    class Foo {
    
      public function bar()
      {
          try {
              // ...
          } catch (Exception $e) {} // empty catch block
      }
    }

    Source https://phpmd.org/rules/design.html#emptycatchblock

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                            $utm = [
                                "utm_source=reminder",
                                "utm_medium=email",
                                sprintf("utm_campaign=%s", ContentUtility::generateUrlSlug($this->title))
                            ];
    Severity: Major
    Found in lib/Reminders/Reminder.php and 1 other location - About 1 hr to fix
    lib/Newsletters/Utility/NewsletterUtility.php on lines 58..62

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 36.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                if (!filter_var($this->object_id, FILTER_VALIDATE_INT) || $this->object_id == 0) {
                    throw new Exception("Can't lookup a reminder because no object ID was specified");
                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php and 1 other location - About 55 mins to fix
    lib/News/Article.php on lines 438..440

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 29.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

                            $joiner = strpos($email['hero']['link'], "?") === false ? "?" : "&";
    Severity: Major
    Found in lib/Reminders/Reminder.php and 2 other locations - About 50 mins to fix
    lib/Reminders/Reminder.php on lines 332..334
    lib/Reminders/Reminder.php on lines 336..338

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 27.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

                            if (strpos($email['hero']['link'], "railpage.com.au") === false) {
                                $email['hero']['link'] = sprintf("http://www.railpage.com.au%s", (string) $Object->url);
                            }
    Severity: Major
    Found in lib/Reminders/Reminder.php and 2 other locations - About 50 mins to fix
    lib/Reminders/Reminder.php on lines 332..334
    lib/Reminders/Reminder.php on lines 346..346

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 27.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

                $Notification->addRecipient($this->User->id, $this->User->username, $this->User->contact_email); 
    Severity: Major
    Found in lib/Reminders/Reminder.php and 2 other locations - About 50 mins to fix
    lib/Images/Utility/CompNotify.php on lines 72..72
    lib/PrivateMessages/Message.php on lines 424..424

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 27.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

                            if (strpos($email['hero']['link'], "http://") === false) {
                                $email['hero']['link'] = "http://www.railpage.com.au" . $email['hero']['link']; 
                            }
    Severity: Major
    Found in lib/Reminders/Reminder.php and 2 other locations - About 50 mins to fix
    lib/Reminders/Reminder.php on lines 336..338
    lib/Reminders/Reminder.php on lines 346..346

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 27.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

                    "dispatched" => $this->Dispatched instanceof DateTime ? $this->Dispatched->format("Y-m-d H:i:s") : "0000-00-00 00:00:00"
    Severity: Major
    Found in lib/Reminders/Reminder.php and 7 other locations - About 45 mins to fix
    lib/Images/Competition.php on lines 314..314
    lib/Images/Competition.php on lines 315..315
    lib/Images/Competition.php on lines 316..316
    lib/Images/Competition.php on lines 317..317
    lib/Notifications/Notification.php on lines 225..225
    lib/SiteMessages/SiteMessage.php on lines 158..158
    lib/SiteMessages/SiteMessage.php on lines 159..159

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 26.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 31 locations. Consider refactoring.
    Open

                        $this->url->send = sprintf("/reminders?id=%d&mode=send", $this->id);
    Severity: Major
    Found in lib/Reminders/Reminder.php and 30 other locations - About 40 mins to fix
    lib/Content/Page.php on lines 155..155
    lib/Events/EventDate.php on lines 161..161
    lib/Feedback/FeedbackItem.php on lines 147..147
    lib/Feedback/FeedbackItem.php on lines 148..148
    lib/Feedback/FeedbackItem.php on lines 154..154
    lib/Feedback/FeedbackItem.php on lines 155..155
    lib/Forums/Post.php on lines 749..749
    lib/Forums/Post.php on lines 750..750
    lib/Forums/Post.php on lines 751..751
    lib/Forums/Post.php on lines 752..752
    lib/Forums/Post.php on lines 753..753
    lib/Forums/Post.php on lines 754..754
    lib/Forums/Post.php on lines 755..755
    lib/Forums/Post.php on lines 756..756
    lib/Ideas/Idea.php on lines 207..207
    lib/Images/Camera.php on lines 131..131
    lib/Images/Competition.php on lines 431..431
    lib/Locos/Operator.php on lines 114..114
    lib/Locos/Operator.php on lines 115..115
    lib/News/Article.php on lines 481..481
    lib/News/Article.php on lines 482..482
    lib/News/Article.php on lines 483..483
    lib/News/Article.php on lines 484..484
    lib/News/Article.php on lines 485..485
    lib/Newsletters/Newsletter.php on lines 267..267
    lib/Newsletters/Newsletter.php on lines 268..268
    lib/Newsletters/Newsletter.php on lines 269..269
    lib/Newsletters/Newsletter.php on lines 270..270
    lib/SiteMessages/SiteMessage.php on lines 193..193
    lib/SiteMessages/SiteMessage.php on lines 194..194

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 23.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

                if (filter_var($id, FILTER_VALIDATE_INT) && $id > 0) {
                    $this->id = $id;
                }
    Severity: Major
    Found in lib/Reminders/Reminder.php and 3 other locations - About 40 mins to fix
    lib/Gallery/Album.php on lines 264..266
    lib/Images/Image.php on lines 1265..1267
    lib/Railcams/Type.php on lines 52..64

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 23.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                    $this->db->delete("reminders", array("id = ?" => $this->id));
    Severity: Minor
    Found in lib/Reminders/Reminder.php and 1 other location - About 35 mins to fix
    lib/News/Article.php on lines 595..595

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 22.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    The parameter $EventDate is not named in camelCase.
    Open

            public function setReminderDate(DateTime $Reminder, DateTime $EventDate) {
                
                $Now = new DateTime;
                
                if ($EventDate <= $Now) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $Reminder is not named in camelCase.
    Open

            public function setReminderDate(DateTime $Reminder, DateTime $EventDate) {
                
                $Now = new DateTime;
                
                if ($EventDate <= $Now) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    Blank line found at end of control structure
    Open

                    
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Blank line found at start of control structure
    Open

                } catch (Exception $e) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $namespace;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function send($markAsSent = false) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $sent = false;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 24 spaces, found 28
    Open

                                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function setReminderDate(DateTime $Reminder, DateTime $EventDate) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 20 spaces, found 24
    Open

                            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        class Reminder extends AppCore {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $title;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function commit() {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 16 spaces, found 24
    Open

                            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function exists() {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->object)) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 16 spaces, found 20
    Open

                        if ($CoverPhoto = (new Images)->getImageFromUrl($Object->meta['coverphoto'])) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if ($markAsSent) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if ($Reminder <= $Now) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 16 spaces, found 20
    Open

                        if ($Reminder <= $Now) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!filter_var($this->object_id, FILTER_VALIDATE_INT) || $this->object_id == 0) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 16 spaces, found 24
    Open

                            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                } catch (Exception $e) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if ($Reminder <= $Now) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $Module;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$this->Module instanceof Module) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if ($EventDate <= $Now) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if ($Reminder >= $EventDate) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $object;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                } else {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($this->id, FILTER_VALIDATE_INT)) {   
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                try {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 16 spaces, found 20
    Open

                        }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $text;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($id, FILTER_VALIDATE_INT) && $id > 0) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($this->id)) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if ($row = $this->db->fetchRow($query, $this->id)) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if (isset($Object->meta['coverphoto']) && !empty($Object->meta['coverphoto'])) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 24 spaces, found 28
    Open

                                if ($size >= 620) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$this->User instanceof User) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 16 spaces, found 24
    Open

                            if (strpos($email['hero']['link'], "http://") === false) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 16 spaces, found 20
    Open

                        }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private $ThisModule;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$this->Date instanceof DateTime) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($this->id, FILTER_VALIDATE_INT)) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                } else {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 20 spaces, found 24
    Open

                            foreach ($CoverPhoto->sizes as $size) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $id;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 20 spaces, found 24
    Open

                            if ($Reminder <= $Now) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $User;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function validate() {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->text)) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if ($id && filter_var($id) && $id > 0) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function delete() {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $object_id;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $Date;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function __construct($id = false) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if (!$this->exists()) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 16 spaces, found 24
    Open

                            if (strpos($email['hero']['link'], "railpage.com.au") === false) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $Dispatched;
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$this->User instanceof User) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 20 spaces, found 24
    Open

                            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->title)) {
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/Reminders/Reminder.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status