File ProductsImport.php
has 652 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace import_export\classes;
use CI_DB_active_record;
- Create a ticketCreate a ticket
Function runProductVariantUpdateQuery
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
private function runProductVariantUpdateQuery(&$arg, &$productId, $EmptyFields) {
/* START product variant insert query block */
$prepareNames = $binds = $updateData = [];
- Read upRead up
- Create a ticketCreate a ticket
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 runProductUpdateQuery
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public function runProductUpdateQuery($productId, $arg, $EmptyFields) {
$insertData = [];
if ($arg['url'] != '') {
$arg['url'] = $this->urlCheck($arg['url'], $productId);
- Read upRead up
- Create a ticketCreate a ticket
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 runProductInsertQuery
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function runProductInsertQuery($arg, $EmptyFields) {
if ($arg['name'] == '') {
Logger::create()
->set('Колонка имени товара пустая. NUM - ' . $arg['num'] . ' insert. - IMPORT');
return;
- Create a ticketCreate a ticket
Method runProductUpdateQuery
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function runProductUpdateQuery($productId, $arg, $EmptyFields) {
$insertData = [];
if ($arg['url'] != '') {
$arg['url'] = $this->urlCheck($arg['url'], $productId);
- Create a ticketCreate a ticket
Method runProductVariantUpdateQuery
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function runProductVariantUpdateQuery(&$arg, &$productId, $EmptyFields) {
/* START product variant insert query block */
$prepareNames = $binds = $updateData = [];
- Create a ticketCreate a ticket
Function updateSProductsCategories
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
private function updateSProductsCategories(&$arg, $productId, $EmptyFields) {
$shopCategoryIds = [];
$updateAddCategories = isset($arg['addcats']) && ('' !== trim($arg['addcats']) || $EmptyFields);
if ($updateAddCategories) {
- Read upRead up
- Create a ticketCreate a ticket
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 runProductInsertQuery
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function runProductInsertQuery($arg, $EmptyFields) {
if ($arg['name'] == '') {
Logger::create()
->set('Колонка имени товара пустая. NUM - ' . $arg['num'] . ' insert. - IMPORT');
return;
- Read upRead up
- Create a ticketCreate a ticket
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 updateSProductsCategories
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function updateSProductsCategories(&$arg, $productId, $EmptyFields) {
$shopCategoryIds = [];
$updateAddCategories = isset($arg['addcats']) && ('' !== trim($arg['addcats']) || $EmptyFields);
if ($updateAddCategories) {
- Create a ticketCreate a ticket
Method runProductVariantInsertQuery
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function runProductVariantInsertQuery(&$arg, &$productId) {
if (isset($arg['prc'])) {
$arg['prc'] = str_replace(',', '.', $arg['prc']);
} else {
$arg['prc'] = 0;
- Create a ticketCreate a ticket
Function runAditionalImages
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function runAditionalImages($arg, $id) {
$this->db->delete('shop_product_images', ['product_id' => $id]);
$arg['imgs'] = explode('|', $arg['imgs']);
- Read upRead up
- Create a ticketCreate a ticket
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 saveImgByUrl
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function saveImgByUrl($param, $type = false) {
if (!$type) {
Logger::create()
->set('$type is false. saveImgByUrl() ProductsImport.php. - IMPORT');
return FALSE;
- Create a ticketCreate a ticket
Function runCopyImages
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function runCopyImages($result) {
foreach ((array) $result as $item) {
if (preg_match('/http\:\/\//i', $item['vimg']) || preg_match('/https\:\/\//i', $item['vimg'])) {
$filename = $this->saveImgByUrl($item['vimg'], 'origin');
if ($filename) {
- Read upRead up
- Create a ticketCreate a ticket
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 runAditionalImages
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function runAditionalImages($arg, $id) {
$this->db->delete('shop_product_images', ['product_id' => $id]);
$arg['imgs'] = explode('|', $arg['imgs']);
- Create a ticketCreate a ticket
Function saveImgByUrl
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function saveImgByUrl($param, $type = false) {
if (!$type) {
Logger::create()
->set('$type is false. saveImgByUrl() ProductsImport.php. - IMPORT');
return FALSE;
- Read upRead up
- Create a ticketCreate a ticket
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 processBrands
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function processBrands() {
$this->load->helper('translit');
foreach (BaseImport::create()->content as $key => $node) {
if (isset($node['brd']) && !empty($node['brd'])) {
$result = $this->db->query(
- Read upRead up
- Create a ticketCreate a ticket
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 runCopyImages
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function runCopyImages($result) {
foreach ((array) $result as $item) {
if (preg_match('/http\:\/\//i', $item['vimg']) || preg_match('/https\:\/\//i', $item['vimg'])) {
$filename = $this->saveImgByUrl($item['vimg'], 'origin');
if ($filename) {
- Create a ticketCreate a ticket
Method processBrands
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processBrands() {
$this->load->helper('translit');
foreach (BaseImport::create()->content as $key => $node) {
if (isset($node['brd']) && !empty($node['brd'])) {
$result = $this->db->query(
- Create a ticketCreate a ticket
Function runProductVariantInsertQuery
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function runProductVariantInsertQuery(&$arg, &$productId) {
if (isset($arg['prc'])) {
$arg['prc'] = str_replace(',', '.', $arg['prc']);
} else {
$arg['prc'] = 0;
- Read upRead up
- Create a ticketCreate a ticket
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
Avoid too many return
statements within this method. Open
return $goodName . '.' . $format;
- Create a ticketCreate a ticket