| Conditions | 6 |
| Paths | 12 |
| Total Lines | 71 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 110 | public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) : array |
||
| 111 | { |
||
| 112 | $context = $this->context(); |
||
| 113 | $manager = \Aimeos\MShop::create( $context, 'product' ); |
||
| 114 | |||
| 115 | /** controller/jobs/product/import/csv/separator |
||
| 116 | * Separator between multiple values in one CSV field |
||
| 117 | * |
||
| 118 | * In Aimeos, fields of some CSV columns can contain multiple values which |
||
| 119 | * are split and imported as separate values. This setting configures the |
||
| 120 | * character that is used for splitting the values and by default, a new |
||
| 121 | * line character (\n) is used. |
||
| 122 | * |
||
| 123 | * @param string Unique character or characters in field values |
||
| 124 | * @since 2015.05 |
||
| 125 | * @see controller/jobs/product/import/csv/domains |
||
| 126 | * @see controller/jobs/product/import/csv/attribute/listtypes |
||
| 127 | * @see controller/jobs/product/import/csv/media/listtypes |
||
| 128 | * @see controller/jobs/product/import/csv/price/listtypes |
||
| 129 | * @see controller/jobs/product/import/csv/product/listtypes |
||
| 130 | * @see controller/jobs/product/import/csv/supplier/listtypes |
||
| 131 | * @see controller/jobs/product/import/csv/text/listtypes |
||
| 132 | */ |
||
| 133 | $separator = $context->config()->get( 'controller/jobs/product/import/csv/separator', "\n" ); |
||
| 134 | |||
| 135 | $pos = 0; |
||
| 136 | $listMap = []; |
||
| 137 | $map = $this->getMappedChunk( $data, $this->getMapping() ); |
||
| 138 | $listItems = $product->getListItems( 'attribute', $this->listTypes, null, false ); |
||
| 139 | |||
| 140 | foreach( $listItems as $listItem ) |
||
| 141 | { |
||
| 142 | if( $refItem = $listItem->getRefItem() ) { |
||
| 143 | $listMap[$refItem->getCode()][$refItem->getType()][$listItem->getType()] = $listItem; |
||
| 144 | } |
||
| 145 | } |
||
| 146 | |||
| 147 | foreach( $map as $list ) |
||
| 148 | { |
||
| 149 | if( $this->checkEntry( $list ) === false ) { |
||
| 150 | continue; |
||
| 151 | } |
||
| 152 | |||
| 153 | $attrType = trim( $this->val( $list, 'attribute.type', '' ) ); |
||
| 154 | $listtype = trim( $this->val( $list, 'product.lists.type', 'default' ) ); |
||
| 155 | $this->addType( 'product/lists/type', 'attribute', $listtype ); |
||
| 156 | |||
| 157 | $listConfig = $this->getListConfig( trim( $this->val( $list, 'product.lists.config', '' ) ) ); |
||
| 158 | unset( $list['product.lists.config'] ); |
||
| 159 | |||
| 160 | $codes = explode( $separator, trim( $this->val( $list, 'attribute.code', '' ) ) ); |
||
| 161 | unset( $list['attribute.code'], $list['product.lists.config'] ); |
||
| 162 | |||
| 163 | foreach( $codes as $code ) |
||
| 164 | { |
||
| 165 | $code = trim( $code ); |
||
| 166 | |||
| 167 | $attrItem = $this->getAttributeItem( $code, $attrType ); |
||
| 168 | $attrItem = $attrItem->fromArray( $list )->setCode( $code ); |
||
| 169 | |||
| 170 | $listItem = $listMap[$code][$attrType][$listtype] ?? $manager->createListItem(); |
||
|
|
|||
| 171 | $listItem = $listItem->setPosition( $pos )->fromArray( $list )->setConfig( $listConfig ); |
||
| 172 | |||
| 173 | $product->addListItem( 'attribute', $listItem->setType( $listtype ), $attrItem ); |
||
| 174 | unset( $listItems[$listItem->getId()] ); |
||
| 175 | } |
||
| 176 | } |
||
| 177 | |||
| 178 | $product->deleteListItems( $listItems ); |
||
| 179 | |||
| 180 | return $this->object()->process( $product, $data ); |
||
| 181 | } |
||
| 240 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.