src/ELearn/Views/Topic.php

Summary

Maintainability
D
2 days
Test Coverage

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

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

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

        public static function findAll($request, $match)
        {
            // check for domain
            if (isset($match['domainId'])) {
                $domainId = $match['domainId'];
    Severity: Minor
    Found in src/ELearn/Views/Topic.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['topicId'])) {
                  $topicId = $match['topicId'];
              } else {
      Severity: Minor
      Found in src/ELearn/Views/Topic.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)
          {
              $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $match['modelId']);
              // check domain
              if (isset($match['domainId'])) {
      Severity: Minor
      Found in src/ELearn/Views/Topic.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)
          {
              $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $match['topicId']);
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '48', column '20').
      Open

              return new Pluf_HTTP_Response_Json($topic);
      Severity: Minor
      Found in src/ELearn/Views/Topic.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('Topic with id (' . $topic->id . ') does not exist in domain with id (' . $domain->id . ')');
      Severity: Minor
      Found in src/ELearn/Views/Topic.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('domain=%s', array(
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '186', column '28').
      Open

              $plufService = new Pluf_Views();
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '66', column '22').
      Open

              $topic = new ELearn_Topic();
      Severity: Minor
      Found in src/ELearn/Views/Topic.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($topic);
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '161', column '27').
      Open

                      throw new Pluf_Exception_DoesNotExist('Topic with id (' . $topicId . ') does not exist in domain with id (' . $domainId . ')');
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '30', column '28').
      Open

              $plufService = new Pluf_Views();
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '25').
      Open

              $searcher = new ELearn_Searcher($topic);
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '166', column '20').
      Open

              return new Pluf_HTTP_Response_Json($topicCopy);
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '116', column '24').
      Open

                  $sql = new Pluf_SQL('domain=%s', array(
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '141', column '20').
      Open

              return new Pluf_HTTP_Response_Json($searcher->render_object());
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '113', column '22').
      Open

              $topic = new ELearn_Topic();
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '95', column '20').
      Open

              return new Pluf_HTTP_Response_Json($paginator->render_object());
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 '182', column '27').
      Open

                      throw new Pluf_Exception_DoesNotExist('Topic with id (' . $topic->id . ') does not exist in domain with id (' . $domain->id . ')');
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 create uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $domainId = $request->REQUEST['domain'];
              }
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 remove 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/Topic.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 "domain" 13 times.
      Open

                  $request->REQUEST['domain'] = $domainId;
      Severity: Critical
      Found in src/ELearn/Views/Topic.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 "creation_dtime" 4 times.
      Open

                  'creation_dtime',
      Severity: Critical
      Found in src/ELearn/Views/Topic.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" 3 times.
      Open

              $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $match['topicId']);
      Severity: Critical
      Found in src/ELearn/Views/Topic.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_Domain" 4 times.
      Open

              Pluf_Shortcuts_GetObjectOr404('ELearn_Domain', $domainId);
      Severity: Critical
      Found in src/ELearn/Views/Topic.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 "owner" 3 times.
      Open

              $request->REQUEST['owner'] = $request->user->id;
      Severity: Critical
      Found in src/ELearn/Views/Topic.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

              $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $match['topicId']);
      Severity: Critical
      Found in src/ELearn/Views/Topic.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 with id (" 3 times.
      Open

                      throw new Pluf_Exception_DoesNotExist('Topic with id (' . $topic->id . ') does not exist in domain with id (' . $domain->id . ')');
      Severity: Critical
      Found in src/ELearn/Views/Topic.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 "modif_dtime" 4 times.
      Open

                  'modif_dtime'
      Severity: Critical
      Found in src/ELearn/Views/Topic.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" 6 times.
      Open

                  'title',
      Severity: Critical
      Found in src/ELearn/Views/Topic.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 "domainId" 14 times.
      Open

              if (isset($match['domainId'])) {
      Severity: Critical
      Found in src/ELearn/Views/Topic.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 ") does not exist in domain with id (" 3 times.
      Open

                      throw new Pluf_Exception_DoesNotExist('Topic with id (' . $topic->id . ') does not exist in domain with id (' . $domain->id . ')');
      Severity: Critical
      Found in src/ELearn/Views/Topic.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.

      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/Topic.php by phan

      Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
      Open

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

      Call to method __construct from undeclared class \Pluf_HTTP_Response_Json
      Open

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

      Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
      Open

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

      Call to method __construct from undeclared class \Pluf_SQL
      Open

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

      Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
      Open

              $request->REQUEST['owner'] = $request->user->id;
      Severity: Minor
      Found in src/ELearn/Views/Topic.php by phan

      Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
      Open

                  $domain = Pluf_Shortcuts_GetObjectOr404('ELearn_Domain', $domainId);
      Severity: Critical
      Found in src/ELearn/Views/Topic.php by phan

      Call to method __construct from undeclared class \Pluf_SQL
      Open

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

      Call to method loadFunction from undeclared class \Pluf
      Open

      Pluf::loadFunction('ELearn_Shortcuts_NormalizeItemPerPage');
      Severity: Critical
      Found in src/ELearn/Views/Topic.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/Topic.php by phan

      Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
      Open

              $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $match['topicId']);
      Severity: Critical
      Found in src/ELearn/Views/Topic.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/Topic.php by phan

      Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
      Open

                  $domain = Pluf_Shortcuts_GetObjectOr404('ELearn_Domain', $domainId);
      Severity: Critical
      Found in src/ELearn/Views/Topic.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/Topic.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/Topic.php by phan

      Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
      Open

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

      Parameter $request has undeclared type \Pluf_HTTP_Request
      Open

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

      Reference to instance property user from undeclared class \Pluf_HTTP_Request
      Open

              $request->REQUEST['owner'] = $request->user->id;
      Severity: Minor
      Found in src/ELearn/Views/Topic.php by phan

      Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
      Open

              Pluf_Shortcuts_GetObjectOr404('ELearn_Domain', $domainId);
      Severity: Critical
      Found in src/ELearn/Views/Topic.php by phan

      Call to method __construct from undeclared class \Pluf_HTTP_Response_Json
      Open

              return new Pluf_HTTP_Response_Json($topicCopy);
      Severity: Critical
      Found in src/ELearn/Views/Topic.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/Topic.php by phan

      Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
      Open

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

      Call to method __construct from undeclared class \Pluf_Views
      Open

              $plufService = new Pluf_Views();
      Severity: Critical
      Found in src/ELearn/Views/Topic.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/Topic.php by phan

      Call to method __construct from undeclared class \Pluf_Exception_DoesNotExist
      Open

                      throw new Pluf_Exception_DoesNotExist('Topic with id (' . $topicId . ') does not exist in domain with id (' . $domainId . ')');
      Severity: Critical
      Found in src/ELearn/Views/Topic.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/Topic.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/Topic.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/Topic.php by phan

      Call to method __construct from undeclared class \Pluf_Exception_DoesNotExist
      Open

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

      Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
      Open

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

      Call to method __construct from undeclared class \Pluf_Paginator
      Open

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

      Call to method setFromRequest from undeclared class \Pluf_Paginator
      Open

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

      Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
      Open

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

      Call to undeclared function \Pluf_Shortcuts_GetObjectOr404()
      Open

                  $domain = Pluf_Shortcuts_GetObjectOr404('ELearn_Domain', $domainId);
      Severity: Critical
      Found in src/ELearn/Views/Topic.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/Topic.php by phan

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

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

      Call to method __construct from undeclared class \Pluf_HTTP_Response_Json
      Open

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

      Call to method __construct from undeclared class \Pluf_Views
      Open

              $plufService = new Pluf_Views();
      Severity: Critical
      Found in src/ELearn/Views/Topic.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/Topic.php by phan

      Call to method __construct from undeclared class \Pluf_Exception_DoesNotExist
      Open

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

      Call to method loadFunction from undeclared class \Pluf
      Open

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

      Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
      Open

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

      Reference to instance property REQUEST from undeclared class \Pluf_HTTP_Request
      Open

              } elseif (isset($request->REQUEST['domain'])) {
      Severity: Minor
      Found in src/ELearn/Views/Topic.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/Topic.php by phan

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

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

      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)
          {
              $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $match['modelId']);
              // check domain
              if (isset($match['domainId'])) {
      Severity: Major
      Found in src/ELearn/Views/Topic.php and 2 other locations - About 5 hrs to fix
      src/ELearn/Views/Course.php on lines 122..141
      src/ELearn/Views/Lesson.php on lines 122..140

      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)
          {
              $topic = Pluf_Shortcuts_GetObjectOr404('ELearn_Topic', $match['topicId']);
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Major
      Found in src/ELearn/Views/Topic.php and 2 other locations - About 3 hrs to fix
      src/ELearn/Views/Course.php on lines 33..49
      src/ELearn/Views/Lesson.php on lines 33..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

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

      class ELearn_Views_Topic
      Severity: Minor
      Found in src/ELearn/Views/Topic.php by phpcodesniffer

      The class ELearn_Views_Topic is not named in CamelCase.
      Open

      class ELearn_Views_Topic
      {
      
          // *******************************************************************
          // Topics of Domain
      Severity: Minor
      Found in src/ELearn/Views/Topic.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

      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/Topic.php by phpcodesniffer

      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/Topic.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 update($request, $match, $p)
      Severity: Minor
      Found in src/ELearn/Views/Topic.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

      Line exceeds 120 characters; contains 143 characters
      Open

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

      Line exceeds 120 characters; contains 147 characters
      Open

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

      Line exceeds 120 characters; contains 147 characters
      Open

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

      Whitespace found at end of line
      Open

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

      Whitespace found at end of line
      Open

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

      Whitespace found at end of line
      Open

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

      Usage of ELSE IF is discouraged; use ELSEIF instead
      Open

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

      Whitespace found at end of line
      Open

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

      Whitespace found at end of line
      Open

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

      Usage of ELSE IF is discouraged; use ELSEIF instead
      Open

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

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

      class ELearn_Views_Topic
      Severity: Minor
      Found in src/ELearn/Views/Topic.php by phpcodesniffer

      Usage of ELSE IF is discouraged; use ELSEIF instead
      Open

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

      Expected 1 newline at end of file; 0 found
      Open

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

      Whitespace found at end of line
      Open

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

      Whitespace found at end of line
      Open

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

      The variable $search_fields is not named in camelCase.
      Open

          public static function find($request, $match)
          {
              // check for domain
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 domain
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 domain
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 findAll($request, $match)
          {
              // check for domain
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 domain
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 findAll($request, $match)
          {
              // check for domain
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 findAll($request, $match)
          {
              // check for domain
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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 findAll($request, $match)
          {
              // check for domain
              if (isset($match['domainId'])) {
                  $domainId = $match['domainId'];
      Severity: Minor
      Found in src/ELearn/Views/Topic.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