| Conditions | 1 |
| Paths | 1 |
| Total Lines | 77 |
| Code Lines | 1 |
| 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 |
||
| 80 | * an unique name. You may use the name of your project for this. If |
||
| 81 | * you've implemented an alternative client class as well, "standard" |
||
| 82 | * should be replaced by the name of the new class. |
||
| 83 | * |
||
| 84 | * @param string Relative path to the template creating code for the catalog list |
||
| 85 | * @since 2021.07 |
||
| 86 | * @category Developer |
||
| 87 | * @see client/html/cms/page/template-body |
||
| 88 | * @see client/html/cms/page/template-header |
||
| 89 | */ |
||
| 90 | $template = $config->get( 'client/html/cms/page/template-cataloglist', 'cms/page/cataloglist/list' ); |
||
| 91 | $domains = $config->get( 'client/html/catalog/lists/domains', ['media', 'media/property', 'price', 'text'] ); |
||
| 92 | |||
| 93 | if( $view->config( 'client/html/cms/page/basket-add', false ) ) { |
||
| 94 | $domains = array_merge_recursive( $domains, ['product' => ['default'], 'attribute' => ['variant', 'custom', 'config']] ); |
||
| 95 | } |
||
| 96 | |||
| 97 | libxml_use_internal_errors( true ); |
||
| 98 | |||
| 99 | foreach( $view->pageContent as $content ) |
||
| 100 | { |
||
| 101 | $dom = new \DOMDocument( '1.0', 'UTF-8' ); |
||
| 102 | $dom->loadHTML( '<?xml encoding="utf-8" ?>' . $content, LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD ); |
||
| 103 | $nodes = $dom->getElementsByTagName( 'cataloglist' ); |
||
| 104 | |||
| 105 | while( $nodes->length > 0 ) |
||
| 106 | { |
||
| 107 | $node = $nodes->item( 0 ); |
||
| 108 | $catid = $node->hasAttribute( 'catid' ) ? $node->getAttribute( 'catid' ) : null; |
||
|
|
|||
| 109 | $type = $node->hasAttribute( 'type' ) ? $node->getAttribute( 'type' ) : 'default'; |
||
| 110 | $limit = $node->hasAttribute( 'limit' ) ? $node->getAttribute( 'limit' ) : 3; |
||
| 111 | |||
| 112 | $products = ( clone $cntl )->uses( $domains ) |
||
| 113 | ->category( $catid, $type ) |
||
| 114 | ->slice( 0, $limit ) |
||
| 115 | ->search(); |
||
| 116 | |||
| 117 | $this->addMetaItems( $products, $expire, $tags ); |
||
| 118 | |||
| 119 | $view = $context->view()->set( 'products', $products ); |
||
| 120 | |||
| 121 | if( !$products->isEmpty() && (bool) $config->get( 'client/html/catalog/lists/stock/enable', true ) === true ) { |
||
| 122 | $view->itemsStockUrl = $this->getStockUrl( $view, $products ); |
||
| 123 | } |
||
| 124 | |||
| 125 | $pdom = new \DOMDocument( '1.0', 'UTF-8' ); |
||
| 126 | $pdom->loadHTML( '<?xml encoding="utf-8" ?>' . $view->render( $template ), LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD ); |
||
| 127 | |||
| 128 | $pnode = $dom->importNode( $pdom->documentElement, true ); |
||
| 129 | $node->parentNode->replaceChild( $pnode, $node ); |
||
| 130 | } |
||
| 131 | |||
| 132 | $texts[] = substr( $dom->saveHTML(), 25 ); |
||
| 133 | } |
||
| 134 | |||
| 135 | libxml_clear_errors(); |
||
| 136 | |||
| 137 | $view->pageContent = $texts; |
||
| 138 | |||
| 139 | return parent::data( $view, $tags, $expire ); |
||
| 140 | } |
||
| 141 | } |
||
| 142 |
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.