felixarntz/plugin-lib

View on GitHub
src/db-objects/collection.php

Summary

Maintainability
A
2 hrs
Test Coverage

The class Collection has 14 public methods. Consider refactoring Collection to keep number of public methods under 10.
Open

    abstract class Collection implements ArrayAccess, Iterator, Countable {
        /**
         * The manager instance for the collection.
         *
         * @since 1.0.0
Severity: Minor
Found in src/db-objects/collection.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

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

Collection has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

    abstract class Collection implements ArrayAccess, Iterator, Countable {
        /**
         * The manager instance for the collection.
         *
         * @since 1.0.0
Severity: Minor
Found in src/db-objects/collection.php - About 2 hrs to fix

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

            public function to_json( $include_meta = true ) {
                $data = array(
                    'total'  => $this->total,
                    'fields' => $this->fields,
                    'models' => $this->models,
    Severity: Minor
    Found in src/db-objects/collection.php - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Avoid unused parameters such as '$value'.
    Open

            public function offsetSet( $offset, $value ) {
    Severity: Minor
    Found in src/db-objects/collection.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Avoid unused parameters such as '$offset'.
    Open

            public function offsetSet( $offset, $value ) {
    Severity: Minor
    Found in src/db-objects/collection.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Avoid unused parameters such as '$offset'.
    Open

            public function offsetUnset( $offset ) {
    Severity: Minor
    Found in src/db-objects/collection.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    There are no issues that match your filters.

    Category
    Status