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
Function getItemSuggestions
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function getItemSuggestions(
Items $oItem,
$aPossibleSuggestions,
$sSetSuggestions,
$sCurrentitem,
- Read upRead up
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
- Read upRead up
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';
- Read upRead up
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;
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;
- Read upRead up
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 = [];
- Read upRead up
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';
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 = [];
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
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;
Method getItemSuggestions
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getItemSuggestions(
Items $oItem,
$aPossibleSuggestions,
$sSetSuggestions,
$sCurrentitem,
Method getShoppingcartData
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getShoppingcartData()
{
$aCartinfo = [
'numberofitems' => 0,
'cartsums' => [],
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'];
Method buildShoppingCartTable
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function buildShoppingCartTable(array $aCart, $bReadonly = false, $sCustomergroup = '', $aErr = [], $iVATfull = '', $iVATreduced = '')
Method getItemSuggestions
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Items $oItem,
$aPossibleSuggestions,
$sSetSuggestions,
$sCurrentitem,
$mItemindex,
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());
- Read upRead up
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;
- Read upRead up
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;
- Read upRead up
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' => [],
- Read upRead up
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"