serp-spider/core

View on GitHub
src/Core/Url/UrlArchiveTrait.php

Summary

Maintainability
D
2 days
Test Coverage

File UrlArchiveTrait.php has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @license see LICENSE
 */

Severity: Minor
Found in src/Core/Url/UrlArchiveTrait.php - About 3 hrs to fix

    Function resolveAsAlterableUrl has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        private function resolveAsAlterableUrl($url, $as)
        {
            $delta = call_user_func([$as, 'fromString'], $url);
    
            if (!($scheme = $delta->getScheme())) {
    Severity: Minor
    Found in src/Core/Url/UrlArchiveTrait.php - About 3 hrs 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 resolveAsAlterableUrl has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function resolveAsAlterableUrl($url, $as)
        {
            $delta = call_user_func([$as, 'fromString'], $url);
    
            if (!($scheme = $delta->getScheme())) {
    Severity: Minor
    Found in src/Core/Url/UrlArchiveTrait.php - About 1 hr to fix

      Function getAuthority has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getAuthority()
          {
              $authority = '';
      
              if ($host = $this->getHost()) {
      Severity: Minor
      Found in src/Core/Url/UrlArchiveTrait.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 parseStr has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function parseStr($str)
          {
      
              if (!$str) {
                  return [];
      Severity: Minor
      Found in src/Core/Url/UrlArchiveTrait.php - About 1 hr to fix

        Method cloneAs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function cloneAs($as = null)
            {
        
                if (null === $as) {
                    $as = static::class;
        Severity: Minor
        Found in src/Core/Url/UrlArchiveTrait.php - About 1 hr to fix

          Method initWithDefaults has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  $scheme = null,
                  $host = null,
                  $path = null,
                  array $query = [],
                  $hash = null,
          Severity: Major
          Found in src/Core/Url/UrlArchiveTrait.php - About 1 hr to fix

            Function resolve has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function resolve($url, $as = null)
                {
                    if (null === $as) {
                        $as = static::class;
                        $implements = class_implements($as, true);
            Severity: Minor
            Found in src/Core/Url/UrlArchiveTrait.php - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function initWithDefaults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                private function initWithDefaults(
                    $scheme = null,
                    $host = null,
                    $path = null,
                    array $query = [],
            Severity: Minor
            Found in src/Core/Url/UrlArchiveTrait.php - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                public function cloneAs($as = null)
                {
            
                    if (null === $as) {
                        $as = static::class;
            Severity: Minor
            Found in src/Core/Url/UrlArchiveTrait.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

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

                public function buildUrl()
                {
                    $scheme = $this->getScheme();
                    if ($scheme) {
                        $uri = $scheme . ':';
            Severity: Minor
            Found in src/Core/Url/UrlArchiveTrait.php - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            There are no issues that match your filters.

            Category
            Status