lib/Ajde/Config/Repository.php

Summary

Maintainability
A
25 mins
Test Coverage

defaults accesses the super-global variable $_SERVER.
Open

    public function defaults()
    {
        // Current script path
        $scriptPath = $_SERVER['PHP_SELF'];
        $scriptPath = current(explode('index.php', $scriptPath));
Severity: Minor
Found in lib/Ajde/Config/Repository.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

defaults accesses the super-global variable $_SERVER.
Open

    public function defaults()
    {
        // Current script path
        $scriptPath = $_SERVER['PHP_SELF'];
        $scriptPath = current(explode('index.php', $scriptPath));
Severity: Minor
Found in lib/Ajde/Config/Repository.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

defaults accesses the super-global variable $_SERVER.
Open

    public function defaults()
    {
        // Current script path
        $scriptPath = $_SERVER['PHP_SELF'];
        $scriptPath = current(explode('index.php', $scriptPath));
Severity: Minor
Found in lib/Ajde/Config/Repository.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

defaults accesses the super-global variable $_SERVER.
Open

    public function defaults()
    {
        // Current script path
        $scriptPath = $_SERVER['PHP_SELF'];
        $scriptPath = current(explode('index.php', $scriptPath));
Severity: Minor
Found in lib/Ajde/Config/Repository.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

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

    public function readConfigDir($directory)
    {
        $environment = Ajde_Environment::current();

        $searchDirs = [
Severity: Minor
Found in lib/Ajde/Config/Repository.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

Missing class import via use statement (line '37', column '31').
Open

                    throw new Exception('Config file '.$configFile.' contains invalid JSON');
Severity: Minor
Found in lib/Ajde/Config/Repository.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

Avoid using static access to class 'Ajde_Environment' in method 'readConfigDir'.
Open

        $environment = Ajde_Environment::current();
Severity: Minor
Found in lib/Ajde/Config/Repository.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'Ajde_Fs_Find' in method 'readConfigDir'.
Open

            foreach (Ajde_Fs_Find::findFiles($searchDir, '*.json') as $configFile) {
Severity: Minor
Found in lib/Ajde/Config/Repository.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid assigning values to variables in if clauses and the like (line '36', column '22').
Open

    public function readConfigDir($directory)
    {
        $environment = Ajde_Environment::current();

        $searchDirs = [
Severity: Minor
Found in lib/Ajde/Config/Repository.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

TODO found
Open

     * TODO.
Severity: Minor
Found in lib/Ajde/Config/Repository.php by fixme

TODO found
Open

     * TODO.
Severity: Minor
Found in lib/Ajde/Config/Repository.php by fixme

The class Ajde_Config_Repository is not named in CamelCase.
Open

class Ajde_Config_Repository extends Ajde_Object_Standard
{
    /**
     * TODO.
     *
Severity: Minor
Found in lib/Ajde/Config/Repository.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

There are no issues that match your filters.

Category
Status