ampache/ampache

View on GitHub
src/Repository/Model/database_object.php

Summary

Maintainability
A
25 mins
Test Coverage

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

    public function get_info($object_id, $table_name = ''): array
    {
        $table     = $this->getTableName($table_name);
        $object_id = (int)$object_id;

Severity: Minor
Found in src/Repository/Model/database_object.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

syntax error, unexpected '?', expecting function (T_FUNCTION) or const (T_CONST)
Open

    private static ?bool $_enabled = null;
Severity: Critical
Found in src/Repository/Model/database_object.php by phan

The parameter $object_id is not named in camelCase.
Open

    public static function get_from_cache($index, $object_id)
    {
        // Check if the object is set
        if (isset(self::$object_cache[$index][$object_id]) && is_array(self::$object_cache[$index][$object_id])) {
            self::$cache_hit++;

CamelCaseParameterName

Since: 0.2

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

Example

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

Source

The class database_object is not named in CamelCase.
Open

abstract class database_object
{
    protected const DB_TABLENAME = null;

    private static $object_cache = array();

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

The parameter $object_id is not named in camelCase.
Open

    public function get_info($object_id, $table_name = ''): array
    {
        $table     = $this->getTableName($table_name);
        $object_id = (int)$object_id;

CamelCaseParameterName

Since: 0.2

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

Example

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

Source

The parameter $object_id is not named in camelCase.
Open

    public static function is_cached(string $index, $object_id): bool
    {
        // Make sure we've got some parents here before we dive below
        if (!array_key_exists($index, self::$object_cache)) {
            return false;

CamelCaseParameterName

Since: 0.2

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

Example

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

Source

The parameter $table_name is not named in camelCase.
Open

    public function get_info($object_id, $table_name = ''): array
    {
        $table     = $this->getTableName($table_name);
        $object_id = (int)$object_id;

CamelCaseParameterName

Since: 0.2

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

Example

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

Source

The parameter $object_id is not named in camelCase.
Open

    public static function remove_from_cache($index, $object_id = null): void
    {
        if (isset(self::$object_cache[$index])) {
            if (is_null($object_id)) {
                // unset the whole index

CamelCaseParameterName

Since: 0.2

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

Example

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

Source

The parameter $table_name is not named in camelCase.
Open

    private function getTableName($table_name): ?string
    {
        if (!$table_name) {
            $table_name = static::DB_TABLENAME;

CamelCaseParameterName

Since: 0.2

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

Example

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

Source

The parameter $object_id is not named in camelCase.
Open

    public static function add_to_cache($index, $object_id, $data): bool
    {
        /**
         * Lazy load the cache setting to avoid some magic auto_init logic
         */

CamelCaseParameterName

Since: 0.2

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

Example

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

Source

Property name "$_enabled" should not be prefixed with an underscore to indicate visibility
Open

    private static ?bool $_enabled = null;

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

abstract class database_object

There are no issues that match your filters.

Category
Status