efureev/u.php

View on GitHub
src/uString.php

Summary

Maintainability
A
0 mins
Test Coverage

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

    public static function sanitizeString($string, $alpha = true, $strip = true)
Severity: Minor
Found in src/uString.php by phpmd

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 contains has a boolean flag argument $caseSensitive, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function contains($string, $subStr, $caseSensitive = true)
Severity: Minor
Found in src/uString.php by phpmd

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 sanitizeString has a boolean flag argument $alpha, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function sanitizeString($string, $alpha = true, $strip = true)
Severity: Minor
Found in src/uString.php by phpmd

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

Avoid using static access to class 'efureev\uString' in method 'compareString'.
Open

        $expectedLength = uString::byteLength($expected);
Severity: Minor
Found in src/uString.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 'efureev\uString' in method 'compareString'.
Open

        $actualLength = uString::byteLength($actual);
Severity: Minor
Found in src/uString.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

The class uString is not named in CamelCase.
Open

class uString
{

    /**
     * Start string with $startStr
Severity: Minor
Found in src/uString.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

Inline control structures are not allowed
Open

        if ($strip) $string = self::stripSpace($string);
Severity: Minor
Found in src/uString.php by phpcodesniffer

Inline control structures are not allowed
Open

        if ($startStr === '')
Severity: Minor
Found in src/uString.php by phpcodesniffer

Inline control structures are not allowed
Open

        if ($alpha) $string = preg_replace('/[^a-zA-Z 0-9]+/', '', $string);
Severity: Minor
Found in src/uString.php by phpcodesniffer

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

class uString
Severity: Minor
Found in src/uString.php by phpcodesniffer

There are no issues that match your filters.

Category
Status