railpage/railpagecore

View on GitHub
lib/Newsletters/Utility/NewsletterUtility.php

Summary

Maintainability
A
1 hr
Test Coverage

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

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

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

The parameter $Newsletter is not named in camelCase.
Open

        public static function CreateUTMParameters(Newsletter $Newsletter) {
            
            foreach ($Newsletter->content as $k => $row) {
                $url = $row['link'];
                

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 $Newsletter is not named in camelCase.
Open

        public static function CreateUTMParametersForLink(Newsletter $Newsletter, $url) {
            
            if (is_array($url)) {
                $url = $url['url'];
            }

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

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

        }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

        }

Blank line found at end of control structure
Open

                

Line indented incorrectly; expected 4 spaces, found 8
Open

        }

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    class NewsletterUtility {

Line indented incorrectly; expected 8 spaces, found 12
Open

            }

Line indented incorrectly; expected 8 spaces, found 12
Open

            }

Line indented incorrectly; expected 4 spaces, found 8
Open

        }

Line indented incorrectly; expected 4 spaces, found 8
Open

        public static function CreateUTMParametersForLink(Newsletter $Newsletter, $url) {

Line indented incorrectly; expected 8 spaces, found 12
Open

            foreach ($Newsletter->content as $k => $row) {

Line indented incorrectly; expected 4 spaces, found 8
Open

        public static function CreateUTMParameters(Newsletter $Newsletter) {

Line indented incorrectly; expected 8 spaces, found 12
Open

            if (!isset($parts['query'])) {

Line indented incorrectly; expected 8 spaces, found 12
Open

            if (is_array($url)) {

Line indented incorrectly; expected 8 spaces, found 12
Open

            }

There are no issues that match your filters.

Category
Status