src/ELearn/Views/Course.php

Summary

Maintainability
D
2 days
Test Coverage

Method find has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function find($request, $match)
    {
        // check for topic
        if (isset($match['topicId'])) {
            $topicId = $match['topicId'];
Severity: Minor
Found in src/ELearn/Views/Course.php - About 1 hr to fix

    Function remove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function remove($request, $match)
        {
            if (isset($match['courseId'])) {
                $courseId = $match['courseId'];
            } else {
    Severity: Minor
    Found in src/ELearn/Views/Course.php - About 55 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

    Function update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function update($request, $match, $p)
        {
            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $match['modelId']);
            // check topic
            if (isset($match['topicId'])) {
    Severity: Minor
    Found in src/ELearn/Views/Course.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

    Function get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function get($request, $match)
        {
            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $match['courseId']);
            // check topic
            if (isset($match['topicId'])) {
    Severity: Minor
    Found in src/ELearn/Views/Course.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

    Missing class import via use statement (line '66', column '23').
    Open

            $course = new ELearn_Course();
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '67', column '26').
    Open

            $paginator = new Pluf_Paginator($course);
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '69', column '24').
    Open

                $sql = new Pluf_SQL('topic=%s', array(
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '48', column '20').
    Open

            return new Pluf_HTTP_Response_Json($course);
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '119', column '20').
    Open

            return new Pluf_HTTP_Response_Json($courseCopy);
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '114', column '27').
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $courseId . ') does not exist in topic with id (' . $topicId . ')');
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '94', column '20').
    Open

            return new Pluf_HTTP_Response_Json($paginator->render_object());
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '135', column '27').
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $course->id . ') does not exist in topic with id (' . $topic->id . ')');
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '139', column '28').
    Open

            $plufService = new Pluf_Views();
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '45', column '27').
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $course->id . ') does not exist in topic with id (' . $topic->id . ')');
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '29', column '28').
    Open

            $plufService = new Pluf_Views();
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

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

            } else {
                $courseId = $request->REQUEST['courseId'];
            }
    Severity: Minor
    Found in src/ELearn/Views/Course.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

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

            } else {
                $topicId = $request->REQUEST['topic'];
            }
    Severity: Minor
    Found in src/ELearn/Views/Course.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

    Define a constant instead of duplicating this literal ") does not exist in topic with id (" 3 times.
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $course->id . ') does not exist in topic with id (' . $topic->id . ')');
    Severity: Critical
    Found in src/ELearn/Views/Course.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "title" 3 times.
    Open

                'title',
    Severity: Critical
    Found in src/ELearn/Views/Course.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "topicId" 14 times.
    Open

            if (isset($match['topicId'])) {
    Severity: Critical
    Found in src/ELearn/Views/Course.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "ELearn_Course" 4 times.
    Open

            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $match['courseId']);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "ELearn_Topic" 4 times.
    Open

            Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $topicId);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "Course with id (" 3 times.
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $course->id . ') does not exist in topic with id (' . $topic->id . ')');
    Severity: Critical
    Found in src/ELearn/Views/Course.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "topic" 8 times.
    Open

                $request->REQUEST['topic'] = $topicId;
    Severity: Critical
    Found in src/ELearn/Views/Course.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "courseId" 4 times.
    Open

            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $match['courseId']);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Call to method __construct from undeclared class \Pluf_SQL
    Open

                $sql = new Pluf_SQL('topic=%s', array(
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method loadFunction from undeclared class \Pluf
    Open

    Pluf::loadFunction('ELearn_Shortcuts_NormalizeItemPerPage');
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_Views
    Open

            $plufService = new Pluf_Views();
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Return type of find() is undeclared type \Pluf_HTTP_Response_Json
    Open

        public static function find($request, $match)
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Reference to instance property forced_where from undeclared class \Pluf_Paginator
    Open

                $paginator->forced_where = $sql;
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
    Open

            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $match['modelId']);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
    Open

            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $courseId);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Parameter $request has undeclared type \Pluf_HTTP_Request
    Open

        public static function create($request, $match, $p)
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
    Open

                $request->REQUEST['topic'] = $topicId;
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
    Open

            Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $topicId);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_HTTP_Response_Json
    Open

            return new Pluf_HTTP_Response_Json($course);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_Exception_DoesNotExist
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $courseId . ') does not exist in topic with id (' . $topicId . ')');
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_Views
    Open

            $plufService = new Pluf_Views();
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
    Open

                $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $topicId);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method setFromRequest from undeclared class \Pluf_Paginator
    Open

            $paginator->setFromRequest($request);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method render_object from undeclared class \Pluf_Paginator
    Open

            return new Pluf_HTTP_Response_Json($paginator->render_object());
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method updateObject from undeclared class \Pluf_Views
    Open

            return $plufService->updateObject($request, $match, $p);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Return type of create() is undeclared type \Pluf_HTTP_Response
    Open

        public static function create($request, $match, $p)
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Reference to instance property list_filters from undeclared class \Pluf_Paginator
    Open

            $paginator->list_filters = array(
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Call to method createObject from undeclared class \Pluf_Views
    Open

            return $plufService->createObject($request, $match, $p);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_HTTP_Response_Json
    Open

            return new Pluf_HTTP_Response_Json($paginator->render_object());
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
    Open

            $courseCopy = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $courseId);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method loadFunction from undeclared class \Pluf
    Open

    Pluf::loadFunction('Pluf_Shortcuts_GetObjectOr404');
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method configure from undeclared class \Pluf_Paginator
    Open

            $paginator->configure(array(), $search_fields, $sort_fields);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
    Open

                $topicId = $request->REQUEST['topic'];
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_Exception_DoesNotExist
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $course->id . ') does not exist in topic with id (' . $topic->id . ')');
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_HTTP_Response_Json
    Open

            return new Pluf_HTTP_Response_Json($courseCopy);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
    Open

            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $match['courseId']);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_Paginator
    Open

            $paginator = new Pluf_Paginator($course);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
    Open

                $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $topicId);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Call to method __construct from undeclared class \Pluf_Exception_DoesNotExist
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $course->id . ') does not exist in topic with id (' . $topic->id . ')');
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Parameter $request has undeclared type \Pluf_HTTP_Request
    Open

        public static function find($request, $match)
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
    Open

                $topicId = $request->REQUEST['topicId'];
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
    Open

                $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $topicId);
    Severity: Critical
    Found in src/ELearn/Views/Course.php by phan

    Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
    Open

            } elseif (isset($request->REQUEST['topicId'])) {
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

    Reference to instance property items_per_page from undeclared class \Pluf_Paginator
    Open

            $paginator->items_per_page = ELearn_Shortcuts_NormalizeItemPerPage($request);
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phan

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

        public static function remove($request, $match)
        {
            if (isset($match['courseId'])) {
                $courseId = $match['courseId'];
            } else {
    Severity: Major
    Found in src/ELearn/Views/Course.php and 2 other locations - About 6 hrs to fix
    src/ELearn/Views/Lesson.php on lines 97..120
    src/ELearn/Views/Topic.php on lines 144..167

    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 214.

    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

        public static function update($request, $match, $p)
        {
            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $match['modelId']);
            // check topic
            if (isset($match['topicId'])) {
    Severity: Major
    Found in src/ELearn/Views/Course.php and 2 other locations - About 5 hrs to fix
    src/ELearn/Views/Lesson.php on lines 122..140
    src/ELearn/Views/Topic.php on lines 169..188

    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 194.

    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

        public static function get($request, $match)
        {
            $course = Pluf_Shortcuts_GetObjectOr404('ELearn_Course', $match['courseId']);
            // check topic
            if (isset($match['topicId'])) {
    Severity: Major
    Found in src/ELearn/Views/Course.php and 2 other locations - About 3 hrs to fix
    src/ELearn/Views/Lesson.php on lines 33..49
    src/ELearn/Views/Topic.php on lines 34..49

    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 161.

    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

        public static function create($request, $match, $p)
        {
            // check topic
            if (isset($match['topicId'])) {
                $topicId = $match['topicId'];
    Severity: Major
    Found in src/ELearn/Views/Course.php and 1 other location - About 1 hr to fix
    src/ELearn/Views/Lesson.php on lines 18..31

    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 106.

    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

    Each class must be in a namespace of at least one level (a top-level vendor name)
    Open

    class ELearn_Views_Course
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Avoid variables with short names like $p. Configured minimum length is 3.
    Open

        public static function update($request, $match, $p)
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $p. Configured minimum length is 3.
    Open

        public static function create($request, $match, $p)
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 5 and the first side effect is on line 2.
    Open

    <?php
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    The class ELearn_Views_Course is not named in CamelCase.
    Open

    class ELearn_Views_Course
    {
    
        // *******************************************************************
        // Course of Topic
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

    Line exceeds 120 characters; contains 147 characters
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $course->id . ') does not exist in topic with id (' . $topic->id . ')');
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Line exceeds 120 characters; contains 143 characters
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $courseId . ') does not exist in topic with id (' . $topicId . ')');
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Line exceeds 120 characters; contains 147 characters
    Open

                    throw new Pluf_Exception_DoesNotExist('Course with id (' . $course->id . ') does not exist in topic with id (' . $topic->id . ')');
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * @param array $match            
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * @param Pluf_HTTP_Request $request            
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Usage of ELSE IF is discouraged; use ELSEIF instead
    Open

            } else if (isset($request->REQUEST['topicId'])) {
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Usage of ELSE IF is discouraged; use ELSEIF instead
    Open

            } else if (isset($request->REQUEST['topic'])) {
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Usage of ELSE IF is discouraged; use ELSEIF instead
    Open

            } else if (isset($request->REQUEST['topic'])) {
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Class name "ELearn_Views_Course" is not in camel caps format
    Open

    class ELearn_Views_Course
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * @param Pluf_HTTP_Request $request            
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * @param array $match            
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * @param array $p            
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    Expected 1 newline at end of file; 0 found
    Open

    }
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpcodesniffer

    The variable $sort_fields is not named in camelCase.
    Open

        public static function find($request, $match)
        {
            // check for topic
            if (isset($match['topicId'])) {
                $topicId = $match['topicId'];
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $sort_fields is not named in camelCase.
    Open

        public static function find($request, $match)
        {
            // check for topic
            if (isset($match['topicId'])) {
                $topicId = $match['topicId'];
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $search_fields is not named in camelCase.
    Open

        public static function find($request, $match)
        {
            // check for topic
            if (isset($match['topicId'])) {
                $topicId = $match['topicId'];
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $search_fields is not named in camelCase.
    Open

        public static function find($request, $match)
        {
            // check for topic
            if (isset($match['topicId'])) {
                $topicId = $match['topicId'];
    Severity: Minor
    Found in src/ELearn/Views/Course.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status