php-sap/common

View on GitHub

Showing 273 of 273 total issues

Method cast has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function cast($value)
    {
        static $methods;
        if ($methods === null) {
            $methods = [
Severity: Minor
Found in src/Api/Element.php - About 1 hr to fix

    The class AbstractFunction has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
    Open

    abstract class AbstractFunction extends JsonSerializable implements IFunction
    {
        /**
         * @var IConfiguration
         */
    Severity: Minor
    Found in src/AbstractFunction.php by phpmd

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    Function cast has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function cast($value): array
        {
            if (!is_array($value)) {
                throw new InvalidArgumentException(
                    sprintf(
    Severity: Minor
    Found in src/Api/Table.php - About 35 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 $method($value);
    Severity: Major
    Found in src/Api/Element.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return $value;
      Severity: Major
      Found in src/Api/Element.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                            return hex2bin(trim($value));
        Severity: Major
        Found in src/Api/Element.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return SapDateTime::createFromFormat(SapDateTime::SAP_WEEK, $value);
          Severity: Major
          Found in src/Api/Element.php - About 30 mins to fix

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

                public function getAshost(): string
                {
                    /**
                     * InvalidArgumentException will never be thrown.
                     */
            Severity: Minor
            Found in src/Config/ConfigTypeA.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

            Avoid using static access to class '\phpsap\DateTime\SapDateInterval' in method 'cast'.
            Open

                                return SapDateInterval::createFromDateString($value);
            Severity: Minor
            Found in src/Api/Element.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 '47', column '14').
            Open

                public function getUser(): string
                {
                    /**
                     * InvalidArgumentException will never be thrown.
                     */
            Severity: Minor
            Found in src/Config/ConfigCommon.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

            Avoid using static access to class '\phpsap\DateTime\SapDateTime' in method 'cast'.
            Open

                                return SapDateTime::createFromFormat(SapDateTime::SAP_TIMESTAMP, $value);
            Severity: Minor
            Found in src/Api/Element.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 '\phpsap\DateTime\SapDateTime' in method 'cast'.
            Open

                                return SapDateTime::createFromFormat(SapDateTime::SAP_DATE, $value);
            Severity: Minor
            Found in src/Api/Element.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 '\phpsap\DateTime\SapDateTime' in method 'cast'.
            Open

                                return SapDateTime::createFromFormat(SapDateTime::SAP_WEEK, $value);
            Severity: Minor
            Found in src/Api/Element.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 '84', column '14').
            Open

                public function getSysnr(): string
                {
                    /**
                     * InvalidArgumentException will never be thrown.
                     */
            Severity: Minor
            Found in src/Config/ConfigTypeA.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

            Avoid using static access to class 'phpsap\classes\Api\Value' in method 'constructValue'.
            Open

                    return Value::fromArray($value);
            Severity: Minor
            Found in src/Api/RemoteApi.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 'phpsap\classes\Api\Struct' in method 'constructValue'.
            Open

                        return Struct::fromArray($value);
            Severity: Minor
            Found in src/Api/RemoteApi.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 '111', column '14').
            Open

                public function getClient(): string
                {
                    /**
                     * InvalidArgumentException will never be thrown.
                     */
            Severity: Minor
            Found in src/Config/ConfigCommon.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

            Avoid using static access to class 'phpsap\classes\Api\Table' in method 'constructValue'.
            Open

                        return Table::fromArray($value);
            Severity: Minor
            Found in src/Api/RemoteApi.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 'phpsap\classes\Api\Element' in method 'fromArray'.
            Open

                        $members[] = Element::fromArray($member);
            Severity: Minor
            Found in src/Api/Struct.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 '79', column '14').
            Open

                public function getPasswd(): string
                {
                    /**
                     * InvalidArgumentException will never be thrown.
                     */
            Severity: Minor
            Found in src/Config/ConfigCommon.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

            Severity
            Category
            Status
            Source
            Language