php-yaoi/php-yaoi

View on GitHub
src/Http/Client.php

Summary

Maintainability
D
2 days
Test Coverage

Function fetch has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public function fetch($url = null)
    {
        if (null !== $url) {
            if (strpos($url, '://') === false) {
                $url = $this->getAbsoluteUrl($url);
Severity: Minor
Found in src/Http/Client.php - About 4 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

File Client.php has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Yaoi\Http;

use Yaoi\Http\Client\Driver;
use Yaoi\Http\Client\Settings;
Severity: Minor
Found in src/Http/Client.php - About 4 hrs to fix

    Method fetch has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function fetch($url = null)
        {
            if (null !== $url) {
                if (strpos($url, '://') === false) {
                    $url = $this->getAbsoluteUrl($url);
    Severity: Major
    Found in src/Http/Client.php - About 3 hrs to fix

      Function parseResponseCookies has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function parseResponseCookies()
          {
              $cookies = array();
              $this->parsedHeaders = array();
              foreach ($this->responseHeaders as $hdr) {
      Severity: Minor
      Found in src/Http/Client.php - About 2 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 parseResponseCookies has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function parseResponseCookies()
          {
              $cookies = array();
              $this->parsedHeaders = array();
              foreach ($this->responseHeaders as $hdr) {
      Severity: Minor
      Found in src/Http/Client.php - About 1 hr to fix

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

            private function decodeContent($response)
            {
                if (!empty($this->parsedHeaders['content-encoding'])) {
                    if ($response && 'gzip' == strtolower($this->parsedHeaders['content-encoding']['value'])) {
                        if (!function_exists('gzdecode')) {
        Severity: Minor
        Found in src/Http/Client.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct($settings = null)
            {
                parent::__construct($settings);
                $this->reset();
                if ($this->settings) {
        Severity: Minor
        Found in src/Http/Client.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 $response;
        Severity: Major
        Found in src/Http/Client.php - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status