Admidio/admidio

View on GitHub
src/Session.php

Summary

Maintainability
D
2 days
Test Coverage

File Session.php has 320 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Admidio;

use Admidio\UserInterface\Form;

Severity: Minor
Found in src/Session.php - About 3 hrs to fix

    Session has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Session extends \TableAccess
    {
        /**
         * @var array<string,mixed> Array with all objects of this session object.
         */
    Severity: Minor
    Found in src/Session.php - About 2 hrs to fix

      Method start has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function start(string $cookiePrefix, int $limit = 0, string $path = '', string $domain = '', bool $secure = null, bool $httpOnly = true)
          {
              global $gLogger, $gSetCookieForDomain;
      
              if (headers_sent()) {
      Severity: Minor
      Found in src/Session.php - About 1 hr to fix

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

            public static function start(string $cookiePrefix, int $limit = 0, string $path = '', string $domain = '', bool $secure = null, bool $httpOnly = true)
            {
                global $gLogger, $gSetCookieForDomain;
        
                if (headers_sent()) {
        Severity: Minor
        Found in src/Session.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 setCookie has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function setCookie(
                string $name,
                string $value = '',
                int    $expire = 0,
                string $path = '',
        Severity: Minor
        Found in src/Session.php - About 1 hr to fix

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

              public function refreshAutoLogin()
              {
                  if (array_key_exists($this->cookieAutoLoginId, $_COOKIE)) {
                      // restore user from auto login session
                      $this->mAutoLogin = new \AutoLogin($this->db, $_COOKIE[$this->cookieAutoLoginId]);
          Severity: Minor
          Found in src/Session.php - About 1 hr to fix

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

                public static function setCookie(
                    string $name,
                    string $value = '',
                    int    $expire = 0,
                    string $path = '',
            Severity: Minor
            Found in src/Session.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 setCookie has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    string $name,
                    string $value = '',
                    int    $expire = 0,
                    string $path = '',
                    string $domain = '',
            Severity: Major
            Found in src/Session.php - About 50 mins to fix

              Method start has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static function start(string $cookiePrefix, int $limit = 0, string $path = '', string $domain = '', bool $secure = null, bool $httpOnly = true)
              Severity: Minor
              Found in src/Session.php - About 45 mins to fix

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

                    public function isValidLogin(int $userId): bool
                    {
                        global $gSettingsManager;
                
                        if ($userId > 0) {
                Severity: Minor
                Found in src/Session.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 refreshAutoLogin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function refreshAutoLogin()
                    {
                        if (array_key_exists($this->cookieAutoLoginId, $_COOKIE)) {
                            // restore user from auto login session
                            $this->mAutoLogin = new \AutoLogin($this->db, $_COOKIE[$this->cookieAutoLoginId]);
                Severity: Minor
                Found in src/Session.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 refresh has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function refresh()
                    {
                        global $gCurrentSession, $gCheckIpAddress;
                
                        // read session data from database to update the reload flag
                Severity: Minor
                Found in src/Session.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function __construct(\Database $database, string $cookiePrefix = '')
                    {
                        parent::__construct($database, TBL_SESSIONS, 'ses');
                
                        // determine session id
                Severity: Minor
                Found in src/Session.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