| Conditions | 6 |
| Paths | 12 |
| Total Lines | 59 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 106 | public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) : array |
||
| 107 | { |
||
| 108 | $context = $this->context(); |
||
| 109 | $manager = \Aimeos\MShop::create( $context, 'product' ); |
||
| 110 | $refManager = \Aimeos\MShop::create( $context, 'text' ); |
||
| 111 | |||
| 112 | $pos = 0; |
||
| 113 | $listMap = []; |
||
| 114 | $map = $this->getMappedChunk( $data, $this->getMapping() ); |
||
| 115 | $listItems = $product->getListItems( 'text', $this->listTypes, null, false ); |
||
| 116 | |||
| 117 | foreach( $listItems as $listItem ) |
||
| 118 | { |
||
| 119 | if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
||
| 120 | $listMap[$refItem->getContent()][$refItem->getLanguageId()][$refItem->getType()][$listItem->getType()] = $listItem; |
||
| 121 | } |
||
| 122 | } |
||
| 123 | |||
| 124 | foreach( $map as $list ) |
||
| 125 | { |
||
| 126 | if( $this->checkEntry( $list ) === false ) { |
||
| 127 | continue; |
||
| 128 | } |
||
| 129 | |||
| 130 | $listtype = trim( $this->val( $list, 'product.lists.type', 'default' ) ); |
||
| 131 | $listConfig = $this->getListConfig( trim( $this->val( $list, 'product.lists.config', '' ) ) ); |
||
| 132 | |||
| 133 | unset( $list['product.lists.config'] ); |
||
| 134 | |||
| 135 | $language = trim( $this->val( $list, 'text.languageid', '' ) ); |
||
| 136 | $content = trim( $this->val( $list, 'text.content', '' ) ); |
||
| 137 | $type = trim( $this->val( $list, 'text.type', 'name' ) ); |
||
| 138 | |||
| 139 | $this->addType( 'product/lists/type', 'text', $listtype ); |
||
| 140 | $this->addType( 'text/type', 'product', $type ); |
||
| 141 | |||
| 142 | if( isset( $listMap[$content][$language][$type][$listtype] ) ) |
||
| 143 | { |
||
| 144 | $listItem = $listMap[$content][$language][$type][$listtype]; |
||
| 145 | $refItem = $listItem->getRefItem(); |
||
| 146 | unset( $listItems[$listItem->getId()] ); |
||
| 147 | } |
||
| 148 | else |
||
| 149 | { |
||
| 150 | $listItem = $manager->createListItem()->setType( $listtype ); |
||
|
|
|||
| 151 | $refItem = $refManager->create()->setType( $type ); |
||
| 152 | } |
||
| 153 | |||
| 154 | $listItem = $listItem->setPosition( $pos++ )->fromArray( $list )->setConfig( $listConfig ); |
||
| 155 | |||
| 156 | $label = mb_strcut( strip_tags( trim( $this->val( $list, 'text.content', '' ) ) ), 0, 255 ); |
||
| 157 | $refItem = $refItem->setLabel( $label )->fromArray( $list ); |
||
| 158 | |||
| 159 | $product->addListItem( 'text', $listItem, $refItem ); |
||
| 160 | } |
||
| 161 | |||
| 162 | $product->deleteListItems( $listItems->toArray(), true ); |
||
| 163 | |||
| 164 | return $this->object()->process( $product, $data ); |
||
| 165 | } |
||
| 195 |
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.