| Conditions | 7 |
| Paths | 15 |
| 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 |
||
| 106 | public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data ) : array |
||
| 107 | { |
||
| 108 | $context = $this->context(); |
||
| 109 | $manager = \Aimeos\MShop::create( $context, 'catalog' ); |
||
| 110 | $refManager = \Aimeos\MShop::create( $context, 'media' ); |
||
| 111 | |||
| 112 | /** controller/jobs/catalog/import/csv/separator |
||
| 113 | * Single separator character for multiple entries in one field of the import file |
||
| 114 | * |
||
| 115 | * The catalog importer is able split the content of a field from the import |
||
| 116 | * file into several entries based on the given separator character. Thus, |
||
| 117 | * you can create more compact import files and handle a variable range |
||
| 118 | * of entries better. The default separator character is a new line. |
||
| 119 | * |
||
| 120 | * '''Caution:''' The separator character must not be part of any entry |
||
| 121 | * in the field. Otherwise, you will get invalid entries and the importer |
||
| 122 | * may fail! |
||
| 123 | * |
||
| 124 | * @param string Single separator character |
||
| 125 | * @since 2018.04 |
||
| 126 | * @see controller/jobs/catalog/import/csv/domains |
||
| 127 | * @see controller/jobs/supplier/import/csv/domains |
||
| 128 | */ |
||
| 129 | $separator = $context->config()->get( 'controller/jobs/catalog/import/csv/separator', "\n" ); |
||
| 130 | |||
| 131 | $listMap = []; |
||
| 132 | $map = $this->getMappedChunk( $data, $this->getMapping() ); |
||
| 133 | $listItems = $catalog->getListItems( 'media', $this->listTypes ); |
||
| 134 | |||
| 135 | foreach( $listItems as $listItem ) |
||
| 136 | { |
||
| 137 | if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
||
| 138 | $listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem; |
||
| 139 | } |
||
| 140 | } |
||
| 141 | |||
| 142 | foreach( $map as $pos => $list ) |
||
| 143 | { |
||
| 144 | if( $this->checkEntry( $list ) === false ) { |
||
| 145 | continue; |
||
| 146 | } |
||
| 147 | |||
| 148 | $type = trim( $this->val( $list, 'media.type', 'default' ) ); |
||
| 149 | $listtype = trim( $this->val( $list, 'catalog.lists.type', 'default' ) ); |
||
| 150 | $listConfig = $this->getListConfig( trim( $this->val( $list, 'catalog.lists.config', '' ) ) ); |
||
| 151 | $urls = explode( $separator, $this->val( $list, 'media.url', '' ) ); |
||
| 152 | |||
| 153 | foreach( $urls as $url ) |
||
| 154 | { |
||
| 155 | if( isset( $listMap[$url][$type][$listtype] ) ) |
||
| 156 | { |
||
| 157 | $listItem = $listMap[$url][$type][$listtype]; |
||
| 158 | $refItem = $listItem->getRefItem(); |
||
| 159 | unset( $listItems[$listItem->getId()] ); |
||
| 160 | } |
||
| 161 | else |
||
| 162 | { |
||
| 163 | $listItem = $manager->createListItem()->setType( $listtype ); |
||
|
|
|||
| 164 | $refItem = $refManager->create()->setType( $type ); |
||
| 165 | } |
||
| 166 | |||
| 167 | $listItem = $listItem->setPosition( $pos++ )->fromArray( $list )->setConfig( $listConfig ); |
||
| 168 | $refItem = $refItem->setLabel( $url )->setPreview( $url )->fromArray( $list )->setUrl( $url ); |
||
| 169 | |||
| 170 | $catalog->addListItem( 'media', $listItem, $refItem ); |
||
| 171 | } |
||
| 172 | } |
||
| 173 | |||
| 174 | $catalog->deleteListItems( $listItems->toArray(), true ); |
||
| 175 | |||
| 176 | return $this->object()->process( $catalog, $data ); |
||
| 177 | } |
||
| 207 |
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.