fannie/ordering/OrderItemLib.php
File OrderItemLib.php
has 341 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
@class OrderItemLib
Method getItemBySKU
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static function getItemBySKU($sku)
{
$dbc = self::dbc();
// legacy behavior. + forces entry to be treated
// as a SKU instead of a UPC.
Method getItemByUPC
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static function getItemByUPC($upc)
{
$dbc = self::dbc();
$upc = BarcodeLib::padUPC($upc);
Method memPricing
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function memPricing($cardno)
{
$default = array(
'type' => 'markdown',
'amount' => 0,
Function getItem
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
public static function getItem($upc)
{
if (trim($upc) !== '' && !preg_match('/^0+$/', trim($upc))) {
$item = self::getItemByUPC($upc);
if ($item !== false) {
- 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 resultToItem
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private static function resultToItem($dbc, $prodR)
{
$prodW = $dbc->fetchRow($prodR);
$ret = self::$generic_item;
foreach ($ret as $key => $val) {
- 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"