Code Duplication    Length = 21-25 lines in 3 locations

core/db_classes/EE_Event.class.php 3 locations

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