| Conditions | 5 |
| Paths | 8 |
| Total Lines | 180 |
| Code Lines | 24 |
| 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 |
||
| 139 | public function header( string $uid = '' ) : ?string |
||
| 140 | { |
||
| 141 | $config = $this->context()->config(); |
||
| 142 | $view = $this->object()->data( $this->view() ); |
||
| 143 | |||
| 144 | |||
| 145 | $addr = $view->extAddressItem; |
||
| 146 | |||
| 147 | $msg = $view->mail(); |
||
| 148 | $msg->header( 'X-MailGenerator', 'Aimeos' ); |
||
| 149 | $msg->to( $addr->getEMail(), $addr->getFirstName() . ' ' . $addr->getLastName() ); |
||
| 150 | |||
| 151 | |||
| 152 | $fromName = $config->get( 'resource/email/from-name' ); |
||
| 153 | |||
| 154 | /** client/html/email/from-name |
||
| 155 | * @see client/html/email/watch/from-email |
||
| 156 | */ |
||
| 157 | $fromName = $config->get( 'client/html/email/from-name', $fromName ); |
||
| 158 | |||
| 159 | /** client/html/email/watch/from-name |
||
| 160 | * Name used when sending product notification e-mails |
||
| 161 | * |
||
| 162 | * The name of the person or e-mail account that is used for sending all |
||
| 163 | * shop related watch e-mails to customers. This configuration option |
||
| 164 | * overwrite the name set in "client/html/email/from-name". |
||
| 165 | * |
||
| 166 | * @param string Name shown in the e-mail |
||
| 167 | * @since 2014.03 |
||
| 168 | * @category User |
||
| 169 | * @see client/html/email/from-name |
||
| 170 | * @see client/html/email/from-email |
||
| 171 | * @see client/html/email/reply-email |
||
| 172 | * @see client/html/email/bcc-email |
||
| 173 | */ |
||
| 174 | $fromNameWatch = $config->get( 'client/html/email/watch/from-name', $fromName ); |
||
| 175 | |||
| 176 | $fromEmail = $config->get( 'resource/email/from-email' ); |
||
| 177 | |||
| 178 | /** client/html/email/from-email |
||
| 179 | * @see client/html/email/watch/from-email |
||
| 180 | */ |
||
| 181 | $fromEmail = $config->get( 'client/html/email/from-email', $fromEmail ); |
||
| 182 | |||
| 183 | /** client/html/email/watch/from-email |
||
| 184 | * E-Mail address used when sending product notification e-mails |
||
| 185 | * |
||
| 186 | * The e-mail address of the person or account that is used for sending |
||
| 187 | * all shop related product notification e-mails to customers. This configuration option |
||
| 188 | * overwrites the e-mail address set via "client/html/email/from-email". |
||
| 189 | * |
||
| 190 | * @param string E-mail address |
||
| 191 | * @since 2014.03 |
||
| 192 | * @category User |
||
| 193 | * @see client/html/email/watch/from-name |
||
| 194 | * @see client/html/email/from-email |
||
| 195 | * @see client/html/email/reply-email |
||
| 196 | * @see client/html/email/bcc-email |
||
| 197 | */ |
||
| 198 | if( ( $fromEmailWatch = $config->get( 'client/html/email/watch/from-email', $fromEmail ) ) != null ) { |
||
| 199 | $msg->from( $fromEmailWatch, $fromNameWatch ); |
||
| 200 | } |
||
| 201 | |||
| 202 | |||
| 203 | /** client/html/email/reply-name |
||
| 204 | * @see client/html/email/watch/reply-email |
||
| 205 | */ |
||
| 206 | $replyName = $config->get( 'client/html/email/reply-name', $fromName ); |
||
| 207 | |||
| 208 | /** client/html/email/watch/reply-name |
||
| 209 | * Recipient name displayed when the customer replies to product notification e-mails |
||
| 210 | * |
||
| 211 | * The name of the person or e-mail account the customer should |
||
| 212 | * reply to in case of watch related questions or problems. This |
||
| 213 | * configuration option overwrites the name set via |
||
| 214 | * "client/html/email/reply-name". |
||
| 215 | * |
||
| 216 | * @param string Name shown in the e-mail |
||
| 217 | * @since 2014.03 |
||
| 218 | * @category User |
||
| 219 | * @see client/html/email/watch/reply-email |
||
| 220 | * @see client/html/email/reply-name |
||
| 221 | * @see client/html/email/reply-email |
||
| 222 | * @see client/html/email/from-email |
||
| 223 | * @see client/html/email/bcc-email |
||
| 224 | */ |
||
| 225 | $replyNameWatch = $config->get( 'client/html/email/watch/reply-name', $replyName ); |
||
| 226 | |||
| 227 | /** client/html/email/reply-email |
||
| 228 | * @see client/html/email/watch/reply-email |
||
| 229 | */ |
||
| 230 | $replyEmail = $config->get( 'client/html/email/reply-email', $fromEmail ); |
||
| 231 | |||
| 232 | /** client/html/email/watch/reply-email |
||
| 233 | * E-Mail address used by the customer when replying to product notification e-mails |
||
| 234 | * |
||
| 235 | * The e-mail address of the person or e-mail account the customer |
||
| 236 | * should reply to in case of watch related questions or problems. |
||
| 237 | * This configuration option overwrites the e-mail address set via |
||
| 238 | * "client/html/email/reply-email". |
||
| 239 | * |
||
| 240 | * @param string E-mail address |
||
| 241 | * @since 2014.03 |
||
| 242 | * @category User |
||
| 243 | * @see client/html/email/watch/reply-name |
||
| 244 | * @see client/html/email/reply-email |
||
| 245 | * @see client/html/email/from-email |
||
| 246 | * @see client/html/email/bcc-email |
||
| 247 | */ |
||
| 248 | if( ( $replyEmailWatch = $config->get( 'client/html/email/watch/reply-email', $replyEmail ) ) != null ) { |
||
| 249 | $msg->replyTo( $replyEmailWatch, $replyNameWatch ); |
||
| 250 | } |
||
| 251 | |||
| 252 | |||
| 253 | /** client/html/email/bcc-email |
||
| 254 | * @see client/html/email/watch/bcc-email |
||
| 255 | */ |
||
| 256 | $bccEmail = $config->get( 'client/html/email/bcc-email' ); |
||
| 257 | |||
| 258 | /** client/html/email/watch/bcc-email |
||
| 259 | * E-Mail address all product notification e-mails should be also sent to |
||
| 260 | * |
||
| 261 | * Using this option you can send a copy of all watch related e-mails |
||
| 262 | * to a second e-mail account. This can be handy for testing and checking |
||
| 263 | * the e-mails sent to customers. |
||
| 264 | * |
||
| 265 | * It also allows shop owners with a very small volume of orders to be |
||
| 266 | * notified about watch changes. Be aware that this isn't useful if the |
||
| 267 | * order volumne is high or has peeks! |
||
| 268 | * |
||
| 269 | * This configuration option overwrites the e-mail address set via |
||
| 270 | * "client/html/email/bcc-email". |
||
| 271 | * |
||
| 272 | * @param string|array E-mail address or list of e-mail addresses |
||
| 273 | * @since 2014.03 |
||
| 274 | * @category User |
||
| 275 | * @category Developer |
||
| 276 | * @see client/html/email/bcc-email |
||
| 277 | * @see client/html/email/reply-email |
||
| 278 | * @see client/html/email/from-email |
||
| 279 | */ |
||
| 280 | if( ( $bccEmailWatch = $config->get( 'client/html/email/watch/bcc-email', $bccEmail ) ) != null ) |
||
| 281 | { |
||
| 282 | foreach( (array) $bccEmailWatch as $emailAddr ) { |
||
| 283 | $msg->Bcc( $emailAddr ); |
||
| 284 | } |
||
| 285 | } |
||
| 286 | |||
| 287 | |||
| 288 | /** client/html/email/watch/template-header |
||
| 289 | * Relative path to the HTML header template of the product notification e-mail client. |
||
| 290 | * |
||
| 291 | * The template file contains the HTML code and processing instructions |
||
| 292 | * to generate the HTML code that is inserted into the HTML page header |
||
| 293 | * of the rendered page in the frontend. The configuration string is the |
||
| 294 | * path to the template file relative to the templates directory (usually |
||
| 295 | * in client/html/templates). |
||
| 296 | * |
||
| 297 | * You can overwrite the template file configuration in extensions and |
||
| 298 | * provide alternative templates. These alternative templates should be |
||
| 299 | * named like the default one but suffixed by |
||
| 300 | * an unique name. You may use the name of your project for this. If |
||
| 301 | * you've implemented an alternative client class as well, it |
||
| 302 | * should be suffixed by the name of the new class. |
||
| 303 | * |
||
| 304 | * The product notification e-mail HTML client allows to use a different template for |
||
| 305 | * each watch status value. You can create a template for each watch |
||
| 306 | * status and store it in the "email/watch/<status number>/" directory |
||
| 307 | * below the "templates" directory (usually in client/html/templates). If no |
||
| 308 | * specific layout template is found, the common template in the |
||
| 309 | * "email/watch/" directory is used. |
||
| 310 | * |
||
| 311 | * @param string Relative path to the template creating code for the HTML page head |
||
| 312 | * @since 2014.03 |
||
| 313 | * @category Developer |
||
| 314 | * @see client/html/email/watch/template-body |
||
| 315 | */ |
||
| 316 | $tplconf = 'client/html/email/watch/template-header'; |
||
| 317 | |||
| 318 | return $view->render( $view->config( $tplconf, 'email/watch/header' ) ); ; |
||
| 319 | } |
||
| 449 |