t1gor/Robots.txt-Parser-Class

View on GitHub
source/Parser/DirectiveProcessors/HostProcessor.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid unused parameters such as '$prevLine'.
Open

    public function process(string $line, array & $root, string & $currentUserAgent = '*', string $prevLine = '') {

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid using static access to class '\t1gor\RobotsTxtParser\Parser\HostName' in method 'process'.
Open

            '{ipAddress}' => HostName::isIpAddress($entry) ? ' (IP address is not a valid hostname)' : '',

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 '\t1gor\RobotsTxtParser\Parser\HostName' in method 'process'.
Open

        if (HostName::isValid($entry)) {

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

Opening brace of a class must be on the line after the definition
Open

class HostProcessor extends AbstractDirectiveProcessor implements DirectiveProcessorInterface {

Spaces must be used to indent lines; tabs are not allowed
Open

        if (HostName::isValid($entry)) {

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->log(strtr('{directive} with value {faulty} dropped for {useragent} as invalid{ipAddress}', [

Spaces must be used to indent lines; tabs are not allowed
Open

        ]));

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            '{ipAddress}' => HostName::isIpAddress($entry) ? ' (IP address is not a valid hostname)' : '',

Spaces must be used to indent lines; tabs are not allowed
Open

        $parts = explode(':', $line);

Spaces must be used to indent lines; tabs are not allowed
Open

            return;

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function process(string $line, array & $root, string & $currentUserAgent = '*', string $prevLine = '') {

Spaces must be used to indent lines; tabs are not allowed
Open

        $entry       = implode(':', $trimmed);

Spaces must be used to indent lines; tabs are not allowed
Open

            '{directive}' => Directive::HOST,

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getDirectiveName(): string {

Spaces must be used to indent lines; tabs are not allowed
Open

        return Directive::HOST;

Spaces must be used to indent lines; tabs are not allowed
Open

        array_shift($parts);

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            $root[$currentUserAgent][Directive::HOST] = $entry;

Spaces must be used to indent lines; tabs are not allowed
Open

            '{faulty}'    => $entry,

Spaces must be used to indent lines; tabs are not allowed
Open

        $trimmed     = array_map('trim', $parts);

Spaces must be used to indent lines; tabs are not allowed
Open

            '{useragent}' => $currentUserAgent,

Opening brace should be on a new line
Open

    public function process(string $line, array & $root, string & $currentUserAgent = '*', string $prevLine = '') {

Opening brace should be on a new line
Open

    public function getDirectiveName(): string {

There are no issues that match your filters.

Category
Status