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