Code Duplication    Length = 17-18 lines in 4 locations

includes/class-sensei-emails.php 4 locations

@@ 310-327 (lines=18) @@
307
	 * @access public
308
	 * @return void
309
	 */
310
	function teacher_started_course( $learner_id = 0, $course_id = 0 ) {
311
312
313
		$send = false;
314
315
		if( isset( Sensei()->settings->settings['email_teachers'] ) ) {
316
			if( in_array( 'teacher-started-course', (array) Sensei()->settings->settings['email_teachers'] ) ) {
317
				$send = true;
318
			}
319
		} else {
320
			$send = true;
321
		}
322
323
		if( $send ) {
324
			$email = $this->emails['teacher-started-course'];
325
			$email->trigger( $learner_id, $course_id );
326
		}
327
	}
328
329
    /**
330
     * teacher_completed_lesson()
@@ 338-355 (lines=18) @@
335
     * @return void
336
     * @since 1.9.0
337
     */
338
    function teacher_completed_lesson( $learner_id = 0, $lesson_id = 0 ) {
339
340
341
        $send = false;
342
343
        if( isset( Sensei()->settings->settings[ 'email_teachers' ] ) ) {
344
            if( in_array( 'teacher-completed-lesson', (array) Sensei()->settings->settings[ 'email_teachers' ]) ) {
345
                $send = true;
346
            }
347
        } else {
348
            $send = true;
349
        }
350
351
        if( $send ) {
352
            $email = $this->emails['teacher-completed-lesson'];
353
            $email->trigger( $learner_id, $lesson_id );
354
        }
355
    }
356
357
	/**
358
	 * Send email to teacher on quiz submission
@@ 395-411 (lines=17) @@
392
	 * @access public
393
	 * @return void
394
	 */
395
	function teacher_new_message( $message_id = 0 ) {
396
397
		$send = false;
398
399
		if( isset( Sensei()->settings->settings['email_teachers'] ) ) {
400
			if( in_array( 'teacher-new-message', (array) Sensei()->settings->settings['email_teachers'] ) ) {
401
				$send = true;
402
			}
403
		} else {
404
			$send = true;
405
		}
406
407
		if( $send ) {
408
			$email = $this->emails['teacher-new-message'];
409
			$email->trigger( $message_id );
410
		}
411
	}
412
413
	/**
414
	 * Send email to a user when their private message receives a reply
@@ 419-435 (lines=17) @@
416
	 * @access public
417
	 * @return void
418
	 */
419
	function new_message_reply( $comment, $message ) {
420
421
		$send = false;
422
423
		if( isset( Sensei()->settings->settings['email_global'] ) ) {
424
			if( in_array( 'new-message-reply', (array) Sensei()->settings->settings['email_global'] ) ) {
425
				$send = true;
426
			}
427
		} else {
428
			$send = true;
429
		}
430
431
		if( $send ) {
432
			$email = $this->emails['new-message-reply'];
433
			$email->trigger( $comment, $message );
434
		}
435
	}
436
437
}//end class
438