| Conditions | 11 |
| Paths | 8 |
| Total Lines | 59 |
| Code Lines | 25 |
| 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 |
||
| 110 | public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], ?string &$expire = null ) : \Aimeos\Base\View\Iface |
||
| 111 | { |
||
| 112 | $context = $this->context(); |
||
| 113 | $domains = ['media', 'price', 'text']; |
||
| 114 | |||
| 115 | /** client/html/checkout/standard/payment/domains |
||
| 116 | * List of domain names whose items should be available in the checkout payment templates |
||
| 117 | * |
||
| 118 | * The templates rendering checkout payment related data usually add the |
||
| 119 | * images, prices and texts associated to each item. If you want to display |
||
| 120 | * additional content like the attributes, you can configure your own list |
||
| 121 | * of domains (attribute, media, price, text, etc. are domains) whose items |
||
| 122 | * are fetched from the storage. |
||
| 123 | * |
||
| 124 | * @param array List of domain names |
||
| 125 | * @since 2019.04 |
||
| 126 | * @see client/html/checkout/standard/delivery/domains |
||
| 127 | */ |
||
| 128 | $domains = $context->config()->get( 'client/html/checkout/standard/payment/domains', $domains ); |
||
| 129 | |||
| 130 | $basketCntl = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
||
| 131 | $serviceCntl = \Aimeos\Controller\Frontend::create( $context, 'service' ); |
||
| 132 | |||
| 133 | $services = []; |
||
| 134 | $basket = $basketCntl->get(); |
||
| 135 | $providers = $serviceCntl->uses( $domains )->type( 'payment' )->getProviders(); |
||
| 136 | $orderServices = map( $basket->getService( 'payment' ) )->col( null, 'order.service.serviceid' ); |
||
| 137 | |||
| 138 | foreach( $providers as $id => $provider ) |
||
| 139 | { |
||
| 140 | if( $provider->isAvailable( $basket ) === true ) |
||
| 141 | { |
||
| 142 | $attr = $provider->getConfigFE( $basket ); |
||
| 143 | |||
| 144 | if( $oservice = $orderServices->get( $id ) ) |
||
| 145 | { |
||
| 146 | foreach( $attr as $key => $item ) |
||
| 147 | { |
||
| 148 | $value = is_array( $item->getDefault() ) ? key( $item->getDefault() ) : $item->getDefault(); |
||
| 149 | $value = $oservice->getAttribute( $key ) ?: $value; |
||
| 150 | $item->value = $oservice->getAttribute( $key, 'hidden' ) ?: $value; |
||
| 151 | } |
||
| 152 | } |
||
| 153 | else |
||
| 154 | { |
||
| 155 | foreach( $attr as $key => $item ) { |
||
| 156 | $item->value = is_array( $item->getDefault() ) ? key( $item->getDefault() ) : $item->getDefault(); |
||
| 157 | } |
||
| 158 | } |
||
| 159 | |||
| 160 | $services[$id] = $provider->getServiceItem()->set( 'attributes', $attr ) |
||
| 161 | ->set( 'price', $provider->calcPrice( $basket ) ); |
||
| 162 | } |
||
| 163 | } |
||
| 164 | |||
| 165 | $view->paymentServices = $services; |
||
| 166 | $view->paymentOption = $view->param( 'c_paymentoption', $orderServices->firstKey() ?: key( $services ) ); |
||
| 167 | |||
| 168 | return parent::data( $view, $tags, $expire ); |
||
| 169 | } |
||
| 204 |