soliantconsulting/SimpleFM

View on GitHub
src/Client/ResultSet/ResultSetClient.php

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

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

    public function execute(Command $command) : CollectionInterface
    {
        $xml = $this->connection->execute($command, self::GRAMMAR_PATH);
        $errorCode = (int) $xml->error['code'];
        $dataSource = $xml->datasource;
Severity: Minor
Found in src/Client/ResultSet/ResultSetClient.php - About 1 hr to fix

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

        public function execute(Command $command) : CollectionInterface
        {
            $xml = $this->connection->execute($command, self::GRAMMAR_PATH);
            $errorCode = (int) $xml->error['code'];
            $dataSource = $xml->datasource;
    Severity: Minor
    Found in src/Client/ResultSet/ResultSetClient.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

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

        private function parseRecord(SimpleXMLElement $recordData, array $metadata) : array
        {
            $record = $this->createRecord($recordData, $metadata);
    
            if (isset($recordData->relatedset)) {
    Severity: Minor
    Found in src/Client/ResultSet/ResultSetClient.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

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

        private function createRecord(SimpleXMLElement $recordData, array $metadata, int $prefixLength = 0) : array
        {
            $record = [
                'record-id' => (int) $recordData['record-id'],
                'mod-id' => (int) $recordData['mod-id'],
    Severity: Minor
    Found in src/Client/ResultSet/ResultSetClient.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

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

    final class ResultSetClient implements ResultSetClientInterface
    {
        const GRAMMAR_PATH = '/fmi/xml/fmresultset.xml';
    
        /**

    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

    Avoid using static access to class '\Soliant\SimpleFM\Client\ResultSet\Exception\ParseException' in method 'getFieldTransformer'.
    Open

                throw ParseException::fromInvalidFieldType(
                    (string) $fieldDefinition['name'],
                    (string) $fieldDefinition['result']
                );

    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 '\Soliant\SimpleFM\Client\ResultSet\Exception\ParseException' in method 'execute'.
    Open

                throw ParseException::fromConcreteException(
                    (string) $dataSource['database'],
                    (string) $dataSource['table'],
                    (string) $dataSource['layout'],
                    $e

    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 '\Soliant\SimpleFM\Client\Exception\FileMakerException' in method 'execute'.
    Open

                throw FileMakerException::fromErrorCode($errorCode);

    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 '\Soliant\SimpleFM\Client\ResultSet\Exception\UnknownFieldException' in method 'getFieldTransformer'.
    Open

                throw UnknownFieldException::fromUnknownField();

    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 '\Soliant\SimpleFM\Client\ResultSet\Exception\UnknownFieldException' in method 'execute'.
    Open

                throw UnknownFieldException::fromConcreteException(
                    (string) $dataSource['database'],
                    (string) $dataSource['table'],
                    (string) $dataSource['layout'],
                    $e

    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