t1gor/Robots.txt-Parser-Class

View on GitHub
source/RobotsTxtParser.php

Summary

Maintainability
D
2 days
Test Coverage

File RobotsTxtParser.php has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace t1gor\RobotsTxtParser;

use Psr\Log\LoggerAwareInterface;
Severity: Minor
Found in source/RobotsTxtParser.php - About 4 hrs to fix

    The class RobotsTxtParser has an overall complexity of 103 which is very high. The configured complexity threshold is 50.
    Open

    class RobotsTxtParser implements LoggerAwareInterface {
    
        use LogsIfAvailableTrait;
    
        // default encoding
    Severity: Minor
    Found in source/RobotsTxtParser.php by phpmd

    RobotsTxtParser has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class RobotsTxtParser implements LoggerAwareInterface {
    
        use LogsIfAvailableTrait;
    
        // default encoding
    Severity: Minor
    Found in source/RobotsTxtParser.php - About 3 hrs to fix

      Function parseURL has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function parseURL($url) {
              $parsed = parse_url($url);
              if ($parsed === false) {
                  return false;
              } elseif (!isset($parsed['scheme']) || !$this->isValidScheme($parsed['scheme'])) {
      Severity: Minor
      Found in source/RobotsTxtParser.php - About 1 hr 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 render has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function render($eol = "\r\n") {
              $input = $this->getRules();
              krsort($input);
              $output = [];
              foreach ($input as $userAgent => $rules) {
      Severity: Minor
      Found in source/RobotsTxtParser.php - About 1 hr 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

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

          public function render($eol = "\r\n") {
              $input = $this->getRules();
              krsort($input);
              $output = [];
              foreach ($input as $userAgent => $rules) {
      Severity: Minor
      Found in source/RobotsTxtParser.php - About 1 hr to fix

        Function getSitemaps has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getSitemaps(?string $userAgent = null): array {
                $this->buildTree();
                $maps = [];
        
                if (!is_null($userAgent)) {
        Severity: Minor
        Found in source/RobotsTxtParser.php - About 1 hr 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 checkRules has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function checkRules(string $rule, string $path, string $userAgent = '*'): bool {
                // check for disallowed http status code
                if ($this->checkHttpStatusCodeRule()) {
                    return ($rule === Directive::DISALLOW);
                }
        Severity: Minor
        Found in source/RobotsTxtParser.php - About 1 hr 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

        Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                $content,
                string $encoding = self::DEFAULT_ENCODING,
                ?TreeBuilderInterface $treeBuilder = null,
                ?ReaderInterface $reader = null,
                ?UserAgentMatcherInterface $userAgentMatcher = null
        Severity: Minor
        Found in source/RobotsTxtParser.php - About 35 mins to fix

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

              public function getHost(?string $userAgent = null) {
                  $this->buildTree();
          
                  if (!is_null($userAgent)) {
                      $userAgent = $this->userAgentMatcher->getMatching($userAgent, array_keys($this->tree));
          Severity: Minor
          Found in source/RobotsTxtParser.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 $parsed;
          Severity: Major
          Found in source/RobotsTxtParser.php - About 30 mins to fix

            The method parseURL() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
            Open

                protected function parseURL($url) {
                    $parsed = parse_url($url);
                    if ($parsed === false) {
                        return false;
                    } elseif (!isset($parsed['scheme']) || !$this->isValidScheme($parsed['scheme'])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

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

            class RobotsTxtParser implements LoggerAwareInterface {
            
                use LogsIfAvailableTrait;
            
                // default encoding
            Severity: Minor
            Found in source/RobotsTxtParser.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

            Missing class import via use statement (line '236', column '13').
            Open

                    throw new \RuntimeException(WarmingMessages::SET_UA_DEPRECATED);
            Severity: Minor
            Found in source/RobotsTxtParser.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 '\t1gor\RobotsTxtParser\Parser\HostName' in method 'isValidHostName'.
            Open

                    return HostName::isValid($host);
            Severity: Minor
            Found in source/RobotsTxtParser.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 't1gor\RobotsTxtParser\Directive' in method 'checkRuleSwitch'.
            Open

                    switch (Directive::attemptGetInline($rule)) {
            Severity: Minor
            Found in source/RobotsTxtParser.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 't1gor\RobotsTxtParser\Directive' in method 'checkRuleSwitch'.
            Open

                            if ($this->checkHostRule(Directive::stripInline($rule))) {
            Severity: Minor
            Found in source/RobotsTxtParser.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 method getSitemaps uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                    } else {
                        foreach ($this->tree as $userAgentBased) {
                            if (isset($userAgentBased[Directive::SITEMAP]) && !empty($userAgentBased[Directive::SITEMAP])) {
                                $maps = array_merge($maps, $userAgentBased[Directive::SITEMAP]);
                            }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            ElseExpression

            Since: 1.4.0

            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($flag) {
                        // one branch
                    } else {
                        // another branch
                    }
                }
            }

            Source https://phpmd.org/rules/cleancode.html#elseexpression

            The method parseURL uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                    } else {
                        if (!isset($parsed['host']) || !$this->isValidHostName($parsed['host'])) {
                            return false;
                        } else {
                            if (!isset($parsed['port'])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            ElseExpression

            Since: 1.4.0

            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($flag) {
                        // one branch
                    } else {
                        // another branch
                    }
                }
            }

            Source https://phpmd.org/rules/cleancode.html#elseexpression

            Avoid using static access to class 't1gor\RobotsTxtParser\Directive' in method 'checkRuleSwitch'.
            Open

                            if ($this->checkCleanParamRule(Directive::stripInline($rule), $path)) {
            Severity: Minor
            Found in source/RobotsTxtParser.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 method render uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                            } else {
                                $output[] = $directive . ': ' . $value;
                            }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            ElseExpression

            Since: 1.4.0

            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($flag) {
                        // one branch
                    } else {
                        // another branch
                    }
                }
            }

            Source https://phpmd.org/rules/cleancode.html#elseexpression

            The method parseURL uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                        } else {
                            if (!isset($parsed['port'])) {
                                $parsed['port'] = getservbyname($parsed['scheme'], 'tcp');
                                if (!is_int($parsed['port'])) {
                                    return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            ElseExpression

            Since: 1.4.0

            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($flag) {
                        // one branch
                    } else {
                        // another branch
                    }
                }
            }

            Source https://phpmd.org/rules/cleancode.html#elseexpression

            Avoid using static access to class '\t1gor\RobotsTxtParser\Stream\GeneratorBasedReader' in method '__construct'.
            Open

                            ? GeneratorBasedReader::fromStream($content)
            Severity: Minor
            Found in source/RobotsTxtParser.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 '\t1gor\RobotsTxtParser\Parser\DirectiveProcessorsFactory' in method 'buildTree'.
            Open

                            DirectiveProcessorsFactory::getDefault($this->logger),
            Severity: Minor
            Found in source/RobotsTxtParser.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 '\t1gor\RobotsTxtParser\Stream\GeneratorBasedReader' in method '__construct'.
            Open

                            : GeneratorBasedReader::fromString($content);
            Severity: Minor
            Found in source/RobotsTxtParser.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 '\t1gor\RobotsTxtParser\Parser\Url' in method 'isValidScheme'.
            Open

                    return Url::isValidScheme($scheme);
            Severity: Minor
            Found in source/RobotsTxtParser.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 unused private fields such as '$content'.
            Open

                private        $content  = '';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            UnusedPrivateField

            Since: 0.2

            Detects when a private field is declared and/or assigned a value, but not used.

            Example

            class Something
            {
                private static $FOO = 2; // Unused
                private $i = 5; // Unused
                private $j = 6;
                public function addOne()
                {
                    return $this->j++;
                }
            }

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

            Avoid unused private fields such as '$userAgent'.
            Open

                private $userAgent      = '*';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            UnusedPrivateField

            Since: 0.2

            Detects when a private field is declared and/or assigned a value, but not used.

            Example

            class Something
            {
                private static $FOO = 2; // Unused
                private $i = 5; // Unused
                private $j = 6;
                public function addOne()
                {
                    return $this->j++;
                }
            }

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

            Avoid unused parameters such as '$userAgent'.
            Open

                public function setUserAgent(string $userAgent) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            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 variables with short names like $b. Configured minimum length is 3.
            Open

                                usort($value, function ($a, $b) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            Avoid variables with short names like $a. Configured minimum length is 3.
            Open

                                usort($value, function ($a, $b) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            Scope keyword "private" must be followed by a single space
            Open

                private        $content  = '';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

            class RobotsTxtParser implements LoggerAwareInterface {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Blank line found at start of control structure
            Open

                    switch (Directive::attemptGetInline($rule)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            CASE statements must be defined using a colon
            Open

                        case Directive::HOST;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Only one argument is allowed per line in a multi-line function call
            Open

                        $host, [
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private $url = null;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private        $content  = '';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private array                      $tree = [];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function __construct(
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $content,
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (is_null($this->treeBuilder)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        );
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                protected $rules = [];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                // UserAgent
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if ($this->reader instanceof LoggerAwareInterface) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->reader->setLogger($this->logger);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                use LogsIfAvailableTrait;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log('Reader is not passed, using a default one...');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            : GeneratorBasedReader::fromString($content);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                const DEFAULT_ENCODING = 'UTF-8';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                // host set
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->encoding         = $encoding;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (is_null($this->reader)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            ? GeneratorBasedReader::fromStream($content)
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (!empty($this->tree)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $this->logger;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->userAgentMatcher->setLogger($this->logger);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $url
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    ?TreeBuilderInterface $treeBuilder = null,
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->reader = is_resource($content)
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log('UserAgentMatcher is not passed, using a default one...');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if ($this->userAgentMatcher instanceof LoggerAwareInterface) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                protected function parseURL($url) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $parsed = parse_url($url);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return void
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    throw new \RuntimeException(WarmingMessages::SET_UA_DEPRECATED);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if ($this->checkHttpStatusCodeRule()) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    foreach ([Directive::DISALLOW, Directive::ALLOW] as $directive) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        if (!isset($this->tree[$userAgent][$directive])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Check HTTP status code rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->reader->setEncoding($this->encoding);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $param              = explode('&', $array[0]);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $cleanParam;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private string $encoding = '';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    ?UserAgentMatcherInterface $userAgentMatcher = null
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                ) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private static function isValidHostName(string $host): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Line exceeds 120 characters; contains 130 characters
            Open

                    $cleanParam['path'] = isset($array[1]) ? $this->encode_url(preg_replace('/[^A-Za-z0-9\.-\/\*\_]/', '', $array[1])) : '/*';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    !is_null($this->logger) && $url->setLogger($this->logger);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $userAgent
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                // rule match
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                protected ?int $httpStatusCode;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                // url
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->reader           = $reader;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (is_null($this->userAgentMatcher)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private function buildTree() {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            $this->logger
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                    return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // check for disallowed http status code
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $result;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private ?TreeBuilderInterface      $treeBuilder;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->treeBuilder      = $treeBuilder;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->userAgentMatcher = new UserAgentMatcher();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->treeBuilder = new TreeBuilder(
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Validate URL scheme
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // strip multi-spaces
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $cleanParam['param'][] = trim($key);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            if ($this->checkRuleSwitch($robotRule, $path)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                $result = ($rule === $directive);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->tree = $this->treeBuilder->build();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->logger = $logger;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return Url::isValidScheme($scheme);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    } elseif (!isset($parsed['scheme']) || !$this->isValidScheme($parsed['scheme'])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $array      = explode(' ', $rule, 2);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param int $code
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $userAgent - which robot to check for
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                protected function checkRules(string $rule, string $path, string $userAgent = '*'): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return true;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    switch (Directive::attemptGetInline($rule)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            break;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                protected $host = null;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        } else {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                $parsed['port'] = getservbyname($parsed['scheme'], 'tcp');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Line exceeds 120 characters; contains 135 characters
            Open

                    $parsed['custom'] = (isset($parsed['path']) ? $parsed['path'] : '/') . (isset($parsed['query']) ? '?' . $parsed['query'] : '');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $cleanParam = [];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $this->checkRules(Directive::ALLOW, $url->getPath(), $userAgent);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $rule      - rule to check
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $userAgent = $this->userAgentMatcher->getMatching($userAgent, array_keys($this->tree));
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                // rules set
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                // robots.txt http status code
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                // robots.txt file content
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    ?ReaderInterface $reader = null,
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $scheme
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    } else {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        foreach ($this->tree[$userAgent][$directive] as $robotRule) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            // check rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            if ($this->checkHostRule(Directive::stripInline($rule))) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log('Creating a default tree builder as none passed...');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            DirectiveProcessorsFactory::getDefault($this->logger),
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->treeBuilder->setContent($this->reader->getContentIterated());
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function getLogger(): ?LoggerInterface {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return HostName::isValid($host);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            if (!isset($parsed['port'])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return bool
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function isAllowed(string $url, ?string $userAgent = '*'): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @deprecated please check rules for exact user agent instead
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $path      - path to check
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return bool
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $result    = ($rule === Directive::ALLOW);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log("Disallowed by HTTP status code {$this->httpStatusCode}");
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                return true;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                // default encoding
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private ?UserAgentMatcherInterface $userAgentMatcher;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if ($this->encoding !== static::DEFAULT_ENCODING) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // construct a tree builder if not passed
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function setLogger(LoggerInterface $logger): void {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $rule = preg_replace('/\s+/S', ' ', $rule);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return true;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Set UserAgent
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                return true;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // match result
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Check basic rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (mb_strrpos($value, '/') == (mb_strlen($value) - 1)
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $directive = in_array($type, [Directive::CACHE, Directive::CACHE_DELAY])
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log("{$directive} directive (unofficial): Not found, fallback to " . Directive::CRAWL_DELAY . " directive");
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return $this->tree[$userAgent][Directive::CRAWL_DELAY];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @deprecated
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $this->reader->getContentRaw();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private $userAgent      = '*';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private ?ReaderInterface           $reader;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    string $encoding = self::DEFAULT_ENCODING,
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->userAgentMatcher = $userAgentMatcher;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if ($parsed === false) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $parsed['custom'] = (isset($parsed['path']) ? $parsed['path'] : '/') . (isset($parsed['query']) ? '?' . $parsed['query'] : '');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return array
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // strip any invalid characters from path prefix
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $cleanParam['path'] = isset($array[1]) ? $this->encode_url(preg_replace('/[^A-Za-z0-9\.-\/\*\_]/', '', $array[1])) : '/*';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function setHttpStatusCode(int $code): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (!is_int($code) || $code < 100 || $code > 599) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->buildTree();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Check rules
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $path
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $value;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    )) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->buildTree();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        if (!isset($parsed['host']) || !$this->isValidHostName($parsed['host'])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private function explodeCleanParamRule($rule) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // Check each directive for rules, allowed by default
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        case Directive::HOST;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            && !strpos($path, "&$param=")
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $escaped = strtr($this->prepareRegexRule($rule), ['@' => '\@']);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    ) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            $url['host'] . ':' . $url['port'],
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            $url['scheme'] . '://' . $url['host'],
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return true;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string      $url       - url to check
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    !is_null($this->logger) && $url->setLogger($this->logger);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        : Directive::CRAWL_DELAY;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $output[] = '';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->buildTree();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if ($userAgent === null) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return null;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->buildTree();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        if (isset($this->tree[$userAgent][Directive::SITEMAP]) && !empty($this->tree[$userAgent][Directive::SITEMAP])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return bool
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Parse URL
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return array|false
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // split into parameter and path
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->httpStatusCode = $code;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private function checkHttpStatusCodeRule(): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->buildTree();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        // return delay for requested directive
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (isset($this->tree[$userAgent][Directive::CRAWL_DELAY])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return 0;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return array
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    foreach ($input as $userAgent => $rules) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            $directive = ucfirst($directive);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                    return mb_strlen($a) < mb_strlen($b);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $host = $this->getHost();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return [];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (!is_null($userAgent)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                if (!is_int($parsed['port'])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Explode Clean-Param rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $url = new Url($url);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            continue;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        case Directive::CLEAN_PARAM:
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        default:
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        || mb_strrpos($value, '=') == (mb_strlen($value) - 1)
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        ]
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (!isset($this->tree[Directive::CLEAN_PARAM]) || empty($this->tree[Directive::CLEAN_PARAM])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log(Directive::CLEAN_PARAM . ' directive: Not found');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                usort($value, function ($a, $b) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    foreach ($this->tree as $userAgentBased) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        || mb_strrpos($value, '?') == (mb_strlen($value) - 1)
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (substr($value, 0, 2) != '.*') {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $host, [
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function isDisallowed(string $url, string $userAgent = '*'): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            } else {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $userAgent = $this->userAgentMatcher->getMatching($userAgent, array_keys($this->tree));
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    } else {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Set the HTTP status code
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return ($rule === Directive::DISALLOW);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return bool
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (isset($this->httpStatusCode) && $this->httpStatusCode >= 500 && $this->httpStatusCode <= 599) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return true;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $host = trim(str_ireplace(Directive::HOST . ':', '', mb_strtolower($rule)));
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function getCleanParam(): array {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return string
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        if (isset($this->tree[$userAgent][Directive::HOST]) && !empty($this->tree[$userAgent][Directive::HOST])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (mb_strlen($value) > 2 && mb_substr($value, -2) == '\$') {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private function checkHostRule($rule) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log($error_msg, [], LogLevel::ERROR);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            $url['host'],
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            $url['scheme'] . '://' . $url['host'] . ':' . $url['port'],
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log('Rule match: ' . Directive::HOST . ' directive');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return [];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    krsort($input);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if ($host !== null) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function getRules(?string $userAgent = null) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                $maps = array_merge($maps, $userAgentBased[Directive::SITEMAP]);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (preg_match('@' . $escaped . '@', $path)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return true;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $error_msg = WarmingMessages::INLINED_HOST;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (in_array(
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return $this->tree[$userAgent][$directive];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Line exceeds 120 characters; contains 127 characters
            Open

                        $this->log("{$directive} directive (unofficial): Not found, fallback to " . Directive::CRAWL_DELAY . " directive");
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    foreach ($sitemaps as $sitemap) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return string[]|string|null
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $hosts = [];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    foreach ($param as $key) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function setUserAgent(string $userAgent) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Check Clean-Param rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log('Rule match: Path');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                protected function prepareRegexRule(string $value): string {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $value = substr($value, 0, -2) . '$';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $url  = $this->parseURL($this->url);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $this->tree[Directive::CLEAN_PARAM];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $output = [];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            if (is_array($value)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $userAgent = $this->userAgentMatcher->getMatching($userAgent, array_keys($this->tree));
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (isset($this->tree[$userAgent])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            array_push($hosts, $userAgentBased[Directive::HOST]);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (!$this->checkBasicRule($cleanParam['path'], $path)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        ) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (!isset($this->url)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @deprecated
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                    $output[] = $directive . ': ' . $subValue;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $output[] = 'Sitemap: ' . $sitemap;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log(sprintf("No direct match found for '%s', fallback to *", $userAgent));
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return !empty($hosts) ? $hosts : null;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return bool
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function getDelay(string $userAgent = "*", string $type = Directive::CRAWL_DELAY) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (isset($this->tree[$userAgent][$directive])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->buildTree();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function getContent(): string {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Render
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function render($eol = "\r\n") {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $input = $this->getRules();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $output[] = 'User-agent: ' . $userAgent;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return implode($eol, $output);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $userAgent = $this->userAgentMatcher->getMatching($userAgent, array_keys($this->tree));
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            return $this->checkBasicRule($rule, $path);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                // Shorter paths later
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $cleanParam = $this->explodeCleanParamRule($rule);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                });
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private function checkBasicRule(string $rule, string $path): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return $this->tree;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return bool
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // fallback for *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (isset($this->tree['*'])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return $this->tree['*'];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string $eol
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function getHost(?string $userAgent = null) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        foreach ($this->tree as $userAgentBased) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->log(sprintf("Rules not found for the given User-Agent '%s'", $userAgent));
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        if (isset($userAgentBased[Directive::HOST]) && !empty($userAgentBased[Directive::HOST])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $maps = [];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            return $this->tree[$userAgent][Directive::SITEMAP];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            break;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private function checkCleanParamRule($rule, $path) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        if (!strpos($path, "?$param=")
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // change @ to \@
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $escape = ['$' => '\$', '?' => '\?', '.' => '\.', '*' => '.*', '[' => '\[', ']' => '\]'];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            // Not multibyte
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Check Host rule
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @return bool
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            if ($this->checkCleanParamRule(Directive::stripInline($rule), $path)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    if (!is_null($userAgent)) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                $output[] = $directive . ': ' . $value;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            if (isset($userAgentBased[Directive::SITEMAP]) && !empty($userAgentBased[Directive::SITEMAP])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // check if path prefix matches the path of the url we're checking
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $sitemaps = $this->getSitemaps();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->log('Rule match: ' . Directive::CLEAN_PARAM . ' directive');
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @note NULL is returned to public API compatibility reasons. Will be removed in the future.
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $value  = str_replace(array_keys($escape), array_values($escape), $value);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function getSitemaps(?string $userAgent = null): array {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $value .= '.*';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $value = '^' . $value;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * Check url wrapper
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param string|null $userAgent - which robot to check for
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $url = new Url($url);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $this->checkRules(Directive::DISALLOW, $url->getPath(), $userAgent);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->log("$directive directive: Not found");
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                public function getLog(): array {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 *
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        foreach ($rules as $directive => $value) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                                foreach ($value as $subValue) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $output[] = 'Host: ' . $host;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // return all rules
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    // direct match
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $maps;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                private static function isValidScheme($scheme) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    return $parsed;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        $this->log('Invalid HTTP status code, not taken into account.', ['code' => $code], LogLevel::WARNING);
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 */
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                protected function checkRuleSwitch(string $rule, string $path): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                /**
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    foreach ($cleanParam['param'] as $param) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        ? Directive::CACHE_DELAY
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @see RobotsTxtParser::getLogger()
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    }
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $output[] = '';
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                        return $this->tree[$userAgent];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                 * @param ?string $userAgent
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                    $this->buildTree();
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

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

                            return $this->tree[$userAgent][Directive::HOST];
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Line exceeds 120 characters; contains 124 characters
            Open

                        if (isset($this->tree[$userAgent][Directive::SITEMAP]) && !empty($this->tree[$userAgent][Directive::SITEMAP])) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function getLogger(): ?LoggerInterface {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                private static function isValidHostName(string $host): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function setLogger(LoggerInterface $logger): void {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                protected function checkRules(string $rule, string $path, string $userAgent = '*'): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                private static function isValidScheme($scheme) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                private function buildTree() {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function isAllowed(string $url, ?string $userAgent = '*'): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                protected function parseURL($url) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                private function explodeCleanParamRule($rule) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function setHttpStatusCode(int $code): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function getCleanParam(): array {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function getLog(): array {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function setUserAgent(string $userAgent) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                protected function checkRuleSwitch(string $rule, string $path): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function getContent(): string {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                private function checkHostRule($rule) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function getSitemaps(?string $userAgent = null): array {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function getRules(?string $userAgent = null) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                private function checkCleanParamRule($rule, $path) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function render($eol = "\r\n") {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function getHost(?string $userAgent = null) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                private function checkBasicRule(string $rule, string $path): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function getDelay(string $userAgent = "*", string $type = Directive::CRAWL_DELAY) {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                private function checkHttpStatusCodeRule(): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                protected function prepareRegexRule(string $value): string {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            Opening brace should be on a new line
            Open

                public function isDisallowed(string $url, string $userAgent = '*'): bool {
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpcodesniffer

            The variable $error_msg is not named in camelCase.
            Open

                private function checkHostRule($rule) {
                    if (!isset($this->url)) {
                        $error_msg = WarmingMessages::INLINED_HOST;
                        $this->log($error_msg, [], LogLevel::ERROR);
                        return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $error_msg is not named in camelCase.
            Open

                private function checkHostRule($rule) {
                    if (!isset($this->url)) {
                        $error_msg = WarmingMessages::INLINED_HOST;
                        $this->log($error_msg, [], LogLevel::ERROR);
                        return false;
            Severity: Minor
            Found in source/RobotsTxtParser.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            There are no issues that match your filters.

            Category
            Status