| Conditions | 4 | 
| Paths | 2 | 
| Total Lines | 66 | 
| Code Lines | 28 | 
| 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  | 
            ||
| 32 | public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface  | 
            ||
| 33 | 	{ | 
            ||
| 34 | $products = [];  | 
            ||
| 35 | $context = $this->context();  | 
            ||
| 36 | $config = $context->config();  | 
            ||
| 37 | |||
| 38 | /** client/html/account/review/size  | 
            ||
| 39 | * Maximum number of products shown for review  | 
            ||
| 40 | *  | 
            ||
| 41 | * After customers bought products, they can write a review for those items.  | 
            ||
| 42 | * The products bought last will be displayed first for review and this  | 
            ||
| 43 | * setting limits the number of products shown in the account page.  | 
            ||
| 44 | *  | 
            ||
| 45 | * @param int Number of products  | 
            ||
| 46 | * @since 2020.10  | 
            ||
| 47 | * @see client/html/account/review/days-after  | 
            ||
| 48 | */  | 
            ||
| 49 | $size = $config->get( 'client/html/account/review/size', 10 );  | 
            ||
| 50 | |||
| 51 | /** client/html/account/review/days-after  | 
            ||
| 52 | * Number of days after the product can be reviewed  | 
            ||
| 53 | *  | 
            ||
| 54 | * After customers bought products, they can write a review for those items.  | 
            ||
| 55 | * To avoid fake or revenge reviews, the option for reviewing the products is  | 
            ||
| 56 | * shown after the configured number of days to customers.  | 
            ||
| 57 | *  | 
            ||
| 58 | * @param int Number of days  | 
            ||
| 59 | * @since 2020.10  | 
            ||
| 60 | * @see client/html/account/review/size  | 
            ||
| 61 | */  | 
            ||
| 62 | $days = $config->get( 'client/html/account/review/days-after', 0 );  | 
            ||
| 63 | |||
| 64 | $orders = \Aimeos\Controller\Frontend::create( $context, 'order' )  | 
            ||
| 65 | ->compare( '>', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING )  | 
            ||
| 66 | ->compare( '<', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $days * 86400 ) )  | 
            ||
| 67 | ->uses( ['order/base', 'order/base/product'] )  | 
            ||
| 68 | ->sort( '-order.base.ctime' )  | 
            ||
| 69 | ->slice( 0, $size )  | 
            ||
| 70 | ->search();  | 
            ||
| 71 | |||
| 72 | $prodMap = $orders->getBaseItem()->getProducts()->flat()  | 
            ||
| 73 | ->col( 'order.base.product.id', 'order.base.product.productid' );  | 
            ||
| 74 | |||
| 75 | $exclude = \Aimeos\Controller\Frontend::create( $context, 'review' )  | 
            ||
| 76 | ->for( 'product', $prodMap->keys()->toArray() )  | 
            ||
| 77 | ->slice( 0, $prodMap->count() )  | 
            ||
| 78 | ->list()->getRefId();  | 
            ||
| 79 | |||
| 80 | if( ( $prodIds = $prodMap->keys()->diff( $exclude )->toArray() ) !== [] )  | 
            ||
| 81 | 		{ | 
            ||
| 82 | $productItems = \Aimeos\Controller\Frontend::create( $context, 'product' )  | 
            ||
| 83 | ->uses( ['text' => ['name'], 'media' => ['default']] )  | 
            ||
| 84 | ->product( $prodIds )  | 
            ||
| 85 | ->search();  | 
            ||
| 86 | |||
| 87 | foreach( $prodMap as $prodId => $ordProdId )  | 
            ||
| 88 | 			{ | 
            ||
| 89 | 				if( $item = $productItems->get( $prodId ) ) { | 
            ||
| 90 | $products[$prodId] = $item->set( 'orderProductId', $ordProdId );  | 
            ||
| 91 | }  | 
            ||
| 92 | }  | 
            ||
| 93 | }  | 
            ||
| 94 | |||
| 95 | $view->reviewProductItems = map( $products )->filter()->take( $size );  | 
            ||
| 96 | |||
| 97 | return parent::data( $view, $tags, $expire );  | 
            ||
| 98 | }  | 
            ||
| 171 |