Code Duplication    Length = 16-17 lines in 2 locations

core/db_classes/EE_Registration.class.php 2 locations

@@ 491-507 (lines=17) @@
488
     * @throws InvalidInterfaceException
489
     * @throws ReflectionException
490
     */
491
    public function reserve_ticket($update_ticket = false, $source = 'unknown')
492
    {
493
        // only reserve ticket if space is not currently reserved
494
        if ((bool) $this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) !== true) {
495
            $this->update_extra_meta('reserve_ticket', "{$this->ticket_ID()} from {$source}");
496
            // IMPORTANT !!!
497
            // although checking $update_ticket first would be more efficient,
498
            // we NEED to ALWAYS call update_extra_meta(), which is why that is done first
499
            if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true)
500
                && $update_ticket
501
            ) {
502
                $ticket = $this->ticket();
503
                $ticket->increaseReserved(1, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
504
                $ticket->save();
505
            }
506
        }
507
    }
508
509
510
    /**
@@ 522-537 (lines=16) @@
519
     * @throws InvalidInterfaceException
520
     * @throws ReflectionException
521
     */
522
    public function release_reserved_ticket($update_ticket = false, $source = 'unknown')
523
    {
524
        // only release ticket if space is currently reserved
525
        if ((bool) $this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) === true) {
526
            $this->update_extra_meta('release_reserved_ticket', "{$this->ticket_ID()} from {$source}");
527
            // IMPORTANT !!!
528
            // although checking $update_ticket first would be more efficient,
529
            // we NEED to ALWAYS call update_extra_meta(), which is why that is done first
530
            if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, false)
531
                && $update_ticket
532
            ) {
533
                $ticket = $this->ticket();
534
                $ticket->decreaseReserved(1, true, "REG: {$this->ID()} (ln:" . __LINE__ . ')');
535
            }
536
        }
537
    }
538
539
540
    /**