| Conditions | 10 | 
| Paths | 98 | 
| Total Lines | 54 | 
| Code Lines | 30 | 
| 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  | 
            ||
| 46 | public function process( \Aimeos\MShop\Common\Item\Iface $item, \DOMNode $node ) : \Aimeos\MShop\Common\Item\Iface  | 
            ||
| 47 | 	{ | 
            ||
| 48 | \Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Common\Item\ListRef\Iface::class, $item );  | 
            ||
| 49 | |||
| 50 | $listItems = array_reverse( $item->getListItems( 'media', null, null, false ), true );  | 
            ||
| 51 | $resource = $item->getResourceType();  | 
            ||
| 52 | $context = $this->getContext();  | 
            ||
| 53 | |||
| 54 | $listManager = \Aimeos\MShop::create( $context, $resource . '/lists' );  | 
            ||
| 55 | $manager = \Aimeos\MShop::create( $context, 'media' );  | 
            ||
| 56 | |||
| 57 | foreach( $node->childNodes as $refNode )  | 
            ||
| 58 | 		{ | 
            ||
| 59 | 			if( $refNode->nodeName !== 'mediaitem' ) { | 
            ||
| 60 | continue;  | 
            ||
| 61 | }  | 
            ||
| 62 | |||
| 63 | 			if( ( $listItem = array_pop( $listItems ) ) === null ) { | 
            ||
| 64 | $listItem = $listManager->createItem();  | 
            ||
| 65 | }  | 
            ||
| 66 | |||
| 67 | 			if( ( $refItem = $listItem->getRefItem() ) === null ) { | 
            ||
| 68 | $refItem = $manager->createItem();  | 
            ||
| 69 | }  | 
            ||
| 70 | |||
| 71 | $list = [];  | 
            ||
| 72 | |||
| 73 | foreach( $refNode->childNodes as $tag )  | 
            ||
| 74 | 			{ | 
            ||
| 75 | 				if( in_array( $tag->nodeName, ['lists', 'property'] ) ) { | 
            ||
| 76 | $refItem = $this->getProcessor( $tag->nodeName )->process( $refItem, $tag );  | 
            ||
| 77 | 				} else { | 
            ||
| 78 | $list[$tag->nodeName] = $tag->nodeValue;  | 
            ||
| 79 | }  | 
            ||
| 80 | }  | 
            ||
| 81 | |||
| 82 | $refItem = $this->update( $refItem, $list );  | 
            ||
| 83 | |||
| 84 | 			foreach( $refNode->attributes as $attrName => $attrNode ) { | 
            ||
| 85 | $list[$resource . '.' . $attrName] = $attrNode->nodeValue;  | 
            ||
| 86 | }  | 
            ||
| 87 | |||
| 88 | $name = $resource . '.lists.config';  | 
            ||
| 89 | $list[$name] = ( isset( $list[$name] ) ? (array) json_decode( $list[$name] ) : [] );  | 
            ||
| 90 | $name = $resource . '.lists.type';  | 
            ||
| 91 | $list[$name] = ( isset( $list[$name] ) ? $list[$name] : 'default' );  | 
            ||
| 92 | |||
| 93 | $this->addType( $resource . '/lists/type', 'media', $list[$resource . '.lists.type'] );  | 
            ||
| 94 | |||
| 95 | $listItem = $listItem->fromArray( $list );  | 
            ||
| 96 | $item->addListItem( 'media', $listItem, $refItem );  | 
            ||
| 97 | }  | 
            ||
| 98 | |||
| 99 | return $item->deleteListItems( $listItems );  | 
            ||
| 100 | }  | 
            ||
| 135 |