Code Duplication    Length = 4-5 lines in 4 locations

caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 2 locations

@@ 380-384 (lines=5) @@
377
            $datetime = $event->_add_relation_to($datetime, 'Datetime');
378
            // before going any further make sure our dates are setup correctly
379
            // so that the end date is always equal or greater than the start date.
380
            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
381
                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
382
                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
383
                $datetime->save();
384
            }
385
            // now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
386
            // because it is possible there was a new one created for the autosave.
387
            // (save the ID for both key and value to avoid duplications)
@@ 610-613 (lines=4) @@
607
            // $ticket->save();
608
            // before going any further make sure our dates are setup correctly
609
            // so that the end date is always equal or greater than the start date.
610
            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
611
                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
612
                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
613
            }
614
            // let's make sure the base price is handled
615
            $ticket = ! $create_new_TKT
616
                ? $this->_add_prices_to_ticket(

admin_pages/events/Events_Admin_Page.core.php 2 locations

@@ 1195-1199 (lines=5) @@
1192
            $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1193
            // load DTT helper
1194
            // before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1195
            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1196
                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1197
                $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1198
                $DTT->save();
1199
            }
1200
            // now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1201
            $saved_dtt = $DTT;
1202
            $success = ! $success ? $success : $DTT;
@@ 1327-1331 (lines=5) @@
1324
            // update ticket.
1325
            $TKT->save();
1326
            // before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1327
            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1328
                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1329
                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1330
                $TKT->save();
1331
            }
1332
            // initially let's add the ticket to the dtt
1333
            $saved_dtt->_add_relation_to($TKT, 'Ticket');
1334
            $saved_tickets[ $TKT->ID() ] = $TKT;