Code Duplication    Length = 20-22 lines in 2 locations

core/db_classes/EE_Message.class.php 2 locations

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