NatLibFi/Skosmos

View on GitHub
src/model/resolver/WDQSResource.php

Summary

Maintainability
A
1 hr
Test Coverage
A
95%

Method resolve has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function resolve(int $timeout): ?EasyRdf\Resource
    {
        try {
            // unregister the legacy "json" format as it causes problems with CONSTRUCT requests
            EasyRdf\Format::unregister('json');
Severity: Minor
Found in src/model/resolver/WDQSResource.php - About 1 hr to fix

    Missing class import via use statement (line '44', column '27').
    Open

                $client = new EasyRdf\Sparql\Client(self::WDQS_ENDPOINT);
    Severity: Minor
    Found in src/model/resolver/WDQSResource.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 'EasyRdf\Http' in method 'resolve'.
    Open

                $httpclient = EasyRdf\Http::getDefaultHttpClient();
    Severity: Minor
    Found in src/model/resolver/WDQSResource.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 'EasyRdf\Format' in method 'resolve'.
    Open

                EasyRdf\Format::unregister('json');
    Severity: Minor
    Found in src/model/resolver/WDQSResource.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 'EasyRdf\Http' in method 'resolve'.
    Open

                EasyRdf\Http::setDefaultHttpClient($httpclient);
    Severity: Minor
    Found in src/model/resolver/WDQSResource.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

    There are no issues that match your filters.

    Category
    Status