Code Duplication    Length = 21-25 lines in 3 locations

core/db_classes/EE_Event.class.php 3 locations

@@ 774-798 (lines=25) @@
771
     * @return boolean true yes, false no
772
     * @throws \EE_Error
773
     */
774
    public function is_upcoming()
775
    {
776
        // check if event id is present and if this event is published
777
        if ($this->is_inactive()) {
778
            return false;
779
        }
780
        // set initial value
781
        $upcoming = false;
782
        //next let's get all datetimes and loop through them
783
        $datetimes = $this->datetimes_in_chronological_order();
784
        foreach ($datetimes as $datetime) {
785
            if ($datetime instanceof EE_Datetime) {
786
                //if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
787
                if ($datetime->is_expired()) {
788
                    continue;
789
                }
790
                //if this dtt is active then we return false.
791
                if ($datetime->is_active()) {
792
                    return false;
793
                }
794
                //otherwise let's check upcoming status
795
                $upcoming = $datetime->is_upcoming();
796
            }
797
        }
798
        return $upcoming;
799
    }
800
801
@@ 807-831 (lines=25) @@
804
     * @return bool
805
     * @throws \EE_Error
806
     */
807
    public function is_active()
808
    {
809
        // check if event id is present and if this event is published
810
        if ($this->is_inactive()) {
811
            return false;
812
        }
813
        // set initial value
814
        $active = false;
815
        //next let's get all datetimes and loop through them
816
        $datetimes = $this->datetimes_in_chronological_order();
817
        foreach ($datetimes as $datetime) {
818
            if ($datetime instanceof EE_Datetime) {
819
                //if this dtt is expired then we continue cause one of the other datetimes might be active.
820
                if ($datetime->is_expired()) {
821
                    continue;
822
                }
823
                //if this dtt is upcoming then we return false.
824
                if ($datetime->is_upcoming()) {
825
                    return false;
826
                }
827
                //otherwise let's check active status
828
                $active = $datetime->is_active();
829
            }
830
        }
831
        return $active;
832
    }
833
834
@@ 840-860 (lines=21) @@
837
     * @return bool
838
     * @throws \EE_Error
839
     */
840
    public function is_expired()
841
    {
842
        // check if event id is present and if this event is published
843
        if ($this->is_inactive()) {
844
            return false;
845
        }
846
        // set initial value
847
        $expired = false;
848
        //first let's get all datetimes and loop through them
849
        $datetimes = $this->datetimes_in_chronological_order();
850
        foreach ($datetimes as $datetime) {
851
            if ($datetime instanceof EE_Datetime) {
852
                //if this dtt is upcoming or active then we return false.
853
                if ($datetime->is_upcoming() || $datetime->is_active()) {
854
                    return false;
855
                }
856
                //otherwise let's check active status
857
                $expired = $datetime->is_expired();
858
            }
859
        }
860
        return $expired;
861
    }
862
863