sebastianmonzel/webfiles-framework-php

View on GitHub
source/core/datatype/time/MTimestampHelper.php

Summary

Maintainability
A
3 hrs
Test Coverage
F
0%

Method getWeekdayName has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getWeekdayName($identifier)
    {
        switch ($identifier) {
            case 0:
                return "Sonntag";
Severity: Minor
Found in source/core/datatype/time/MTimestampHelper.php - About 1 hr to fix

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

    public static function getWeekdayName($identifier)
    {
        switch ($identifier) {
            case 0:
                return "Sonntag";
Severity: Minor
Found in source/core/datatype/time/MTimestampHelper.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

Avoid too many return statements within this method.
Open

                return "Samstag";
Severity: Major
Found in source/core/datatype/time/MTimestampHelper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return "Freitag";
Severity: Major
Found in source/core/datatype/time/MTimestampHelper.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return "Donnerstag";
Severity: Major
Found in source/core/datatype/time/MTimestampHelper.php - About 30 mins to fix

The method getDay has a boolean flag argument $leadingZero, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function getDay($timestamp, $leadingZero = true)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

The method getMonth has a boolean flag argument $leadingZero, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function getMonth($timestamp, $leadingZero = true)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

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

        } else {
            return date("n", $timestamp);
        }

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 getTimestampFromDojoFromatedDate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $timestamp = mktime('0', '0', '0', '0', '0', '0');
        }

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

Avoid using static access to class 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getDojoFormatedDate'.
Open

        $month = MTimestampHelper::getMonth(intval($timestamp));

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 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getFormatedDate'.
Open

        return MTimestampHelper::getDay($timestamp) . "." . MTimestampHelper::getMonth($timestamp) . "." . MTimestampHelper::getYear($timestamp);

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 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getFormatedTime'.
Open

        return MTimestampHelper::getHour($timestamp) . ":" . MTimestampHelper::getMinute($timestamp);

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

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

        } else {
            return date("j", $timestamp);
        }

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

Avoid using static access to class 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getDojoFormatedDate'.
Open

        $day = MTimestampHelper::getDay(intval($timestamp));

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 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getDojoFormatedTime'.
Open

        $hour = MTimestampHelper::getHour(intval($timestamp));

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 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getFormatedDate'.
Open

        return MTimestampHelper::getDay($timestamp) . "." . MTimestampHelper::getMonth($timestamp) . "." . MTimestampHelper::getYear($timestamp);

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 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getDojoFormatedDate'.
Open

        $year = MTimestampHelper::getYear(intval($timestamp));

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 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getFormatedDate'.
Open

        return MTimestampHelper::getDay($timestamp) . "." . MTimestampHelper::getMonth($timestamp) . "." . MTimestampHelper::getYear($timestamp);

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 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getFormatedTime'.
Open

        return MTimestampHelper::getHour($timestamp) . ":" . MTimestampHelper::getMinute($timestamp);

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 'webfilesframework\core\datatype\time\MTimestampHelper' in method 'getDojoFormatedTime'.
Open

        $minute = MTimestampHelper::getMinute(intval($timestamp));

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

There are no issues that match your filters.

Category
Status