Code Duplication    Length = 21-25 lines in 3 locations

core/db_classes/EE_Event.class.php 3 locations

@@ 739-763 (lines=25) @@
736
     * @return boolean true yes, false no
737
     * @throws EE_Error
738
     */
739
    public function is_upcoming()
740
    {
741
        // check if event id is present and if this event is published
742
        if ($this->is_inactive()) {
743
            return false;
744
        }
745
        // set initial value
746
        $upcoming = false;
747
        //next let's get all datetimes and loop through them
748
        $datetimes = $this->datetimes_in_chronological_order();
749
        foreach ($datetimes as $datetime) {
750
            if ($datetime instanceof EE_Datetime) {
751
                //if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
752
                if ($datetime->is_expired()) {
753
                    continue;
754
                }
755
                //if this dtt is active then we return false.
756
                if ($datetime->is_active()) {
757
                    return false;
758
                }
759
                //otherwise let's check upcoming status
760
                $upcoming = $datetime->is_upcoming();
761
            }
762
        }
763
        return $upcoming;
764
    }
765
766
@@ 771-795 (lines=25) @@
768
     * @return bool
769
     * @throws EE_Error
770
     */
771
    public function is_active()
772
    {
773
        // check if event id is present and if this event is published
774
        if ($this->is_inactive()) {
775
            return false;
776
        }
777
        // set initial value
778
        $active = false;
779
        //next let's get all datetimes and loop through them
780
        $datetimes = $this->datetimes_in_chronological_order();
781
        foreach ($datetimes as $datetime) {
782
            if ($datetime instanceof EE_Datetime) {
783
                //if this dtt is expired then we continue cause one of the other datetimes might be active.
784
                if ($datetime->is_expired()) {
785
                    continue;
786
                }
787
                //if this dtt is upcoming then we return false.
788
                if ($datetime->is_upcoming()) {
789
                    return false;
790
                }
791
                //otherwise let's check active status
792
                $active = $datetime->is_active();
793
            }
794
        }
795
        return $active;
796
    }
797
798
@@ 803-823 (lines=21) @@
800
     * @return bool
801
     * @throws EE_Error
802
     */
803
    public function is_expired()
804
    {
805
        // check if event id is present and if this event is published
806
        if ($this->is_inactive()) {
807
            return false;
808
        }
809
        // set initial value
810
        $expired = false;
811
        //first let's get all datetimes and loop through them
812
        $datetimes = $this->datetimes_in_chronological_order();
813
        foreach ($datetimes as $datetime) {
814
            if ($datetime instanceof EE_Datetime) {
815
                //if this dtt is upcoming or active then we return false.
816
                if ($datetime->is_upcoming() || $datetime->is_active()) {
817
                    return false;
818
                }
819
                //otherwise let's check active status
820
                $expired = $datetime->is_expired();
821
            }
822
        }
823
        return $expired;
824
    }
825
826