yeephp/yeephp

View on GitHub
Yee/Http/Util.php

Summary

Maintainability
C
1 day
Test Coverage

Function setCookieHeader has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public static function setCookieHeader(&$header, $name, $value)
    {
        //Build cookie header
        if (is_array($value)) {
            $domain = '';
Severity: Minor
Found in Yee/Http/Util.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 setCookieHeader has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function setCookieHeader(&$header, $name, $value)
    {
        //Build cookie header
        if (is_array($value)) {
            $domain = '';
Severity: Minor
Found in Yee/Http/Util.php - About 1 hr to fix

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

        public static function deleteCookieHeader(&$header, $name, $value = array())
        {
            //Remove affected cookies from current response header
            $cookiesOld = array();
            $cookiesNew = array();
    Severity: Minor
    Found in Yee/Http/Util.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 serializeCookies has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function serializeCookies(\Yee\Http\Headers &$headers, \Yee\Http\Cookies $cookies, array $config)
        {
            if ($config['cookies.encrypt']) {
                foreach ($cookies as $name => $settings) {
                    if (is_string($settings['expires'])) {
    Severity: Minor
    Found in Yee/Http/Util.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 decodeSecureCookie has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function decodeSecureCookie($value, $secret, $algorithm, $mode)
        {
            if ($value) {
                $value = explode('|', $value);
                if (count($value) === 3 && ((int) $value[0] === 0 || (int) $value[0] > time())) {
    Severity: Minor
    Found in Yee/Http/Util.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

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

        public static function encodeSecureCookie($value, $expires, $secret, $algorithm, $mode)
    Severity: Minor
    Found in Yee/Http/Util.php - About 35 mins to fix

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

          public static function parseCookieHeader($header)
          {
              $cookies = array();
              $header = rtrim($header, "\r\n");
              $headerPieces = preg_split('@\s*[;,]\s*@', $header);
      Severity: Minor
      Found in Yee/Http/Util.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