Code Duplication    Length = 20-22 lines in 2 locations

core/db_classes/EE_Message.class.php 2 locations

@@ 648-667 (lines=20) @@
645
	 * This retrieves the associated template pack with this message.
646
	 * @return EE_Messages_Template_Pack | null
647
	 */
648
	public function get_template_pack() {
649
		/**
650
		 * This is deprecated functionality that will be removed eventually but included here now for backward compat.
651
		 */
652
		if ( ! empty( $this->template_pack ) ) {
653
			return $this->template_pack;
654
		}
655
		/** @type EE_Message_Template_Group $grp */
656
		$grp = $this->get_first_related( 'Message_Template_Group' );
657
		//if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
658
		if ( ! $grp instanceof EE_Message_Template_Group ) {
659
			$grp = EEM_Message_Template_Group::instance()->get_one( array( array(
660
				'MTP_messenger' => $this->messenger(),
661
				'MTP_message_type' => $this->message_type(),
662
				'MTP_is_global' => true
663
			) ) );
664
		}
665
666
		return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack() : null;
667
	}
668
669
670
@@ 676-697 (lines=22) @@
673
	 * Retrieves the variation used for generating this message.
674
	 * @return string
675
	 */
676
	public function get_template_pack_variation() {
677
		/**
678
		 * This is deprecated functionality that will be removed eventually but included here now for backward compat.
679
		 */
680
		if ( ! empty( $this->template_variation ) ) {
681
			return $this->template_variation;
682
		}
683
684
		/** @type EE_Message_Template_Group $grp */
685
		$grp = $this->get_first_related( 'Message_Template_Group' );
686
687
		//if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
688
		if ( ! $grp instanceof EE_Message_Template_Group ) {
689
			$grp = EEM_Message_Template_Group::instance()->get_one( array( array(
690
				'MTP_messenger' => $this->messenger(),
691
				'MTP_message_type' => $this->message_type(),
692
				'MTP_is_global' => true
693
			) ) );
694
		}
695
696
		return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack_variation() : '';
697
	}
698
699
	/**
700
	 * Return the link to the admin details for the object.