HaaseIT/HCSF

View on GitHub
src/Shop/Helper.php

Summary

Maintainability
F
4 days
Test Coverage

File Helper.php has 428 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
    HCSF - A multilingual CMS and Shopsystem
    Copyright (C) 2014  Marcus Haase - mail@marcus.haase.name
Severity: Minor
Found in src/Shop/Helper.php - About 6 hrs to fix

    Function getItemSuggestions has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getItemSuggestions(
            Items $oItem,
            $aPossibleSuggestions,
            $sSetSuggestions,
            $sCurrentitem,
    Severity: Minor
    Found in src/Shop/Helper.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

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

        public function fillSuggestions($suggestions)
        {
            $iNumberOfSuggestions = count($suggestions['default']);
            if ($iNumberOfSuggestions > $this->shop['itemdetail_suggestions']) { // if there are more suggestions than should be displayed, randomly pick as many as to be shown
                $aKeysSuggestions = array_rand($suggestions['default'], $this->shop['itemdetail_suggestions']); // get the array keys that will stay
    Severity: Minor
    Found in src/Shop/Helper.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

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

        public function seekItem(\HaaseIT\HCSF\Page $P, array $aP, Items $oItem)
        {
            // Change pagetype to itemoverview, will be changed back to itemdetail once the item is found
            // if it is not found, we will show the overview
            $aP['pagetype'] = 'itemoverview';
    Severity: Minor
    Found in src/Shop/Helper.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 addAdditionalCostsToItems has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function addAdditionalCostsToItems($aSumme, $iVATfull, $iVATreduced)
        {
            $fGesamtnetto = $aSumme['sumvoll'] + $aSumme['sumerm'];
            $fSteuervoll = $aSumme['sumvoll'] * $iVATfull / 100;
            $fSteuererm = $aSumme['sumerm'] * $iVATreduced / 100;
    Severity: Major
    Found in src/Shop/Helper.php - About 2 hrs to fix

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

          public function handleItemPage(ServiceManager $serviceManager, \HaaseIT\HCSF\Page $P, array $aP)
          {
              $mItemIndex = '';
              if (isset($P->cb_pageconfig->itemindex)) {
                  $mItemIndex = $P->cb_pageconfig->itemindex;
      Severity: Minor
      Found in src/Shop/Helper.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 prepareSuggestions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function prepareSuggestions($sSetSuggestions, array $aPossibleSuggestions, Items $oItem)
          {
              // prepare defined suggestions
              $sSetSuggestions = trim($sSetSuggestions);
              $aDefinedSuggestions = [];
      Severity: Minor
      Found in src/Shop/Helper.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 seekItem has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function seekItem(\HaaseIT\HCSF\Page $P, array $aP, Items $oItem)
          {
              // Change pagetype to itemoverview, will be changed back to itemdetail once the item is found
              // if it is not found, we will show the overview
              $aP['pagetype'] = 'itemoverview';
      Severity: Minor
      Found in src/Shop/Helper.php - About 1 hr to fix

        Method prepareSuggestions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function prepareSuggestions($sSetSuggestions, array $aPossibleSuggestions, Items $oItem)
            {
                // prepare defined suggestions
                $sSetSuggestions = trim($sSetSuggestions);
                $aDefinedSuggestions = [];
        Severity: Minor
        Found in src/Shop/Helper.php - About 1 hr to fix

          Method fillSuggestions has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function fillSuggestions($suggestions)
              {
                  $iNumberOfSuggestions = count($suggestions['default']);
                  if ($iNumberOfSuggestions > $this->shop['itemdetail_suggestions']) { // if there are more suggestions than should be displayed, randomly pick as many as to be shown
                      $aKeysSuggestions = array_rand($suggestions['default'], $this->shop['itemdetail_suggestions']); // get the array keys that will stay
          Severity: Minor
          Found in src/Shop/Helper.php - About 1 hr to fix

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

                public function handleItemPage(ServiceManager $serviceManager, \HaaseIT\HCSF\Page $P, array $aP)
                {
                    $mItemIndex = '';
                    if (isset($P->cb_pageconfig->itemindex)) {
                        $mItemIndex = $P->cb_pageconfig->itemindex;
            Severity: Minor
            Found in src/Shop/Helper.php - About 1 hr to fix

              Method getItemSuggestions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getItemSuggestions(
                      Items $oItem,
                      $aPossibleSuggestions,
                      $sSetSuggestions,
                      $sCurrentitem,
              Severity: Minor
              Found in src/Shop/Helper.php - About 1 hr to fix

                Method getShoppingcartData has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getShoppingcartData()
                    {
                        $aCartinfo = [
                            'numberofitems' => 0,
                            'cartsums' => [],
                Severity: Minor
                Found in src/Shop/Helper.php - About 1 hr to fix

                  Method buildShoppingCartTable has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function buildShoppingCartTable(array $aCart, $bReadonly = false, $sCustomergroup = '', $aErr = [], $iVATfull = '', $iVATreduced = '')
                      {
                          if ($iVATfull === '' && $iVATreduced === '') {
                              $iVATfull = $this->shop['vat']['full'];
                              $iVATreduced = $this->shop['vat']['reduced'];
                  Severity: Minor
                  Found in src/Shop/Helper.php - About 1 hr to fix

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

                        public function buildShoppingCartTable(array $aCart, $bReadonly = false, $sCustomergroup = '', $aErr = [], $iVATfull = '', $iVATreduced = '')
                    Severity: Minor
                    Found in src/Shop/Helper.php - About 45 mins to fix

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

                              Items $oItem,
                              $aPossibleSuggestions,
                              $sSetSuggestions,
                              $sCurrentitem,
                              $mItemindex,
                      Severity: Minor
                      Found in src/Shop/Helper.php - About 45 mins to fix

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

                            public function getShippingcost()
                            {
                                $fShippingcost = $this->shop['shippingcoststandardrate'];
                        
                                $sCountry = $this->helperCustomer->getDefaultCountryByConfig($this->config->getLang());
                        Severity: Minor
                        Found in src/Shop/Helper.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 refreshCartItems has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function refreshCartItems(ServiceManager $serviceManager) // bei login/logout ändern sich ggf die preise, shoppingcart neu berechnen
                            {
                                if (isset($_SESSION['cart']) && is_array($_SESSION['cart'])) {
                                    foreach ($_SESSION['cart'] as $sKey => $aValue) {
                                        $sItemkey = $sKey;
                        Severity: Minor
                        Found in src/Shop/Helper.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 addAdditionalCostsToItems has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function addAdditionalCostsToItems($aSumme, $iVATfull, $iVATreduced)
                            {
                                $fGesamtnetto = $aSumme['sumvoll'] + $aSumme['sumerm'];
                                $fSteuervoll = $aSumme['sumvoll'] * $iVATfull / 100;
                                $fSteuererm = $aSumme['sumerm'] * $iVATreduced / 100;
                        Severity: Minor
                        Found in src/Shop/Helper.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 getShoppingcartData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getShoppingcartData()
                            {
                                $aCartinfo = [
                                    'numberofitems' => 0,
                                    'cartsums' => [],
                        Severity: Minor
                        Found in src/Shop/Helper.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