| Conditions | 12 | 
| Paths | 60 | 
| Total Lines | 71 | 
| Code Lines | 40 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| 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  | 
            ||
| 112 | public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )  | 
            ||
| 113 | 	{ | 
            ||
| 114 | $context = $this->getContext();  | 
            ||
| 115 | $manager = \Aimeos\MShop::create( $context, 'media' );  | 
            ||
| 116 | $listManager = \Aimeos\MShop::create( $context, 'product/lists' );  | 
            ||
| 117 | $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );  | 
            ||
| 118 | |||
| 119 | $listMap = [];  | 
            ||
| 120 | $map = $this->getMappedChunk( $data, $this->getMapping() );  | 
            ||
| 121 | $listItems = $product->getListItems( 'media', $this->listTypes );  | 
            ||
| 122 | |||
| 123 | foreach( $listItems as $listItem )  | 
            ||
| 124 | 		{ | 
            ||
| 125 | 			if( ( $refItem = $listItem->getRefItem() ) !== null ) { | 
            ||
| 126 | $listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem;  | 
            ||
| 127 | }  | 
            ||
| 128 | }  | 
            ||
| 129 | |||
| 130 | foreach( $map as $pos => $list )  | 
            ||
| 131 | 		{ | 
            ||
| 132 | 			if( $this->checkEntry( $list ) === false ) { | 
            ||
| 133 | continue;  | 
            ||
| 134 | }  | 
            ||
| 135 | |||
| 136 | $type = $this->getValue( $list, 'media.type', 'default' );  | 
            ||
| 137 | $listtype = $this->getValue( $list, 'product.lists.type', 'default' );  | 
            ||
| 138 | $urls = explode( $separator, $this->getValue( $list, 'media.url', '' ) );  | 
            ||
| 139 | |||
| 140 | 			if( ( $previews = $this->getValue( $list, 'media.previews' ) ) != null ) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 141 | $previews = explode( $separator, $previews );  | 
            ||
| 142 | }  | 
            ||
| 143 | |||
| 144 | foreach( $urls as $idx => $url )  | 
            ||
| 145 | 			{ | 
            ||
| 146 | $url = trim( $url );  | 
            ||
| 147 | |||
| 148 | if( isset( $listMap[$url][$type][$listtype] ) )  | 
            ||
| 149 | 				{ | 
            ||
| 150 | $listItem = $listMap[$url][$type][$listtype];  | 
            ||
| 151 | $refItem = $listItem->getRefItem();  | 
            ||
| 152 | unset( $listItems[$listItem->getId()] );  | 
            ||
| 153 | }  | 
            ||
| 154 | else  | 
            ||
| 155 | 				{ | 
            ||
| 156 | $listItem = $listManager->createItem()->setType( $listtype );  | 
            ||
| 157 | $refItem = $manager->createItem()->setType( $type );  | 
            ||
| 158 | }  | 
            ||
| 159 | |||
| 160 | $ext = pathinfo( $url, PATHINFO_EXTENSION );  | 
            ||
| 161 | 				if( isset( $this->mimes[$ext] ) ) { | 
            ||
| 162 | $refItem->setMimeType( $this->mimes[$ext] );  | 
            ||
| 163 | }  | 
            ||
| 164 | |||
| 165 | if( is_array( $previews ) && isset( $previews[$idx] )  | 
            ||
| 166 | && ( $map = json_decode( $previews[$idx], true ) ) !== null  | 
            ||
| 167 | 				) { | 
            ||
| 168 | $list['media.previews'] = $map;  | 
            ||
| 169 | 				} else { | 
            ||
| 170 | $refItem->setPreview( $url );  | 
            ||
| 171 | }  | 
            ||
| 172 | |||
| 173 | $listItem = $listItem->setPosition( $pos++ )->fromArray( $list );  | 
            ||
| 174 | $refItem = $refItem->setLabel( $url )->fromArray( $list )->setUrl( $url );  | 
            ||
| 175 | |||
| 176 | $product->addListItem( 'media', $listItem, $refItem );  | 
            ||
| 177 | }  | 
            ||
| 178 | }  | 
            ||
| 179 | |||
| 180 | $product->deleteListItems( $listItems, true );  | 
            ||
| 181 | |||
| 182 | return $this->getObject()->process( $product, $data );  | 
            ||
| 183 | }  | 
            ||
| 213 |