Code Duplication    Length = 20-21 lines in 2 locations

core/db_classes/EE_Datetime.class.php 1 location

@@ 1272-1292 (lines=21) @@
1269
     * @throws InvalidDataTypeException
1270
     * @throws EE_Error
1271
     */
1272
    public function update_sold()
1273
    {
1274
        $count_regs_for_this_datetime = EEM_Registration::instance()->count(
1275
            array(
1276
                array(
1277
                    'STS_ID'                 => EEM_Registration::status_id_approved,
1278
                    'REG_deleted'            => 0,
1279
                    'Ticket.Datetime.DTT_ID' => $this->ID(),
1280
                ),
1281
            )
1282
        );
1283
        $sold = $this->sold();
1284
        if ($count_regs_for_this_datetime > $sold) {
1285
            $this->increase_sold($count_regs_for_this_datetime - $sold);
1286
            $this->save();
1287
        } elseif ($count_regs_for_this_datetime < $sold) {
1288
            $this->decrease_sold($count_regs_for_this_datetime - $sold);
1289
            $this->save();
1290
        }
1291
        return $count_regs_for_this_datetime;
1292
    }
1293
}
1294

core/db_classes/EE_Ticket.class.php 1 location

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