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

@@ 1202-1206 (lines=5) @@
1199
            $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1200
            // load DTT helper
1201
            // 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.
1202
            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1203
                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1204
                $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1205
                $DTT->save();
1206
            }
1207
            // 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.
1208
            $saved_dtt = $DTT;
1209
            $success = ! $success ? $success : $DTT;
@@ 1334-1338 (lines=5) @@
1331
            // update ticket.
1332
            $TKT->save();
1333
            // 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.
1334
            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1335
                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1336
                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1337
                $TKT->save();
1338
            }
1339
            // initially let's add the ticket to the dtt
1340
            $saved_dtt->_add_relation_to($TKT, 'Ticket');
1341
            $saved_tickets[ $TKT->ID() ] = $TKT;