Code Duplication    Length = 18-19 lines in 2 locations

core/db_classes/EE_Datetime.class.php 1 location

@@ 1282-1300 (lines=19) @@
1279
     * @throws InvalidDataTypeException
1280
     * @throws EE_Error
1281
     */
1282
    public function update_sold()
1283
    {
1284
        $count_regs_for_this_datetime = EEM_Registration::instance()->count(
1285
            array(
1286
                array(
1287
                    'STS_ID'                 => EEM_Registration::status_id_approved,
1288
                    'REG_deleted'            => 0,
1289
                    'Ticket.Datetime.DTT_ID' => $this->ID(),
1290
                ),
1291
            )
1292
        );
1293
        $sold = $this->sold();
1294
        if ($count_regs_for_this_datetime > $sold) {
1295
            $this->increase_sold($count_regs_for_this_datetime - $sold);
1296
        } elseif ($count_regs_for_this_datetime < $sold) {
1297
            $this->decrease_sold($count_regs_for_this_datetime - $sold);
1298
        }
1299
        return $count_regs_for_this_datetime;
1300
    }
1301
}
1302

core/db_classes/EE_Ticket.class.php 1 location

@@ 1410-1427 (lines=18) @@
1407
     * @return int
1408
     * @throws \EE_Error
1409
     */
1410
    public function update_tickets_sold()
1411
    {
1412
        $count_regs_for_this_ticket = $this->count_registrations(
1413
            array(
1414
                array(
1415
                    'STS_ID'      => EEM_Registration::status_id_approved,
1416
                    'REG_deleted' => 0,
1417
                ),
1418
            )
1419
        );
1420
        $sold = $this->sold();
1421
        if ($count_regs_for_this_ticket > $sold) {
1422
            $this->increase_sold($count_regs_for_this_ticket - $sold);
1423
        } elseif ($count_regs_for_this_ticket < $sold) {
1424
            $this->decrease_sold($count_regs_for_this_ticket - $sold);
1425
        }
1426
        return $count_regs_for_this_ticket;
1427
    }
1428
1429
1430
    /**