Code Duplication    Length = 18-19 lines in 2 locations

core/db_classes/EE_Datetime.class.php 1 location

@@ 915-932 (lines=18) @@
912
     * @return int
913
     * @throws \EE_Error
914
     */
915
	public function update_sold() {
916
		$count_regs_for_this_datetime = EEM_Registration::instance()->count(
917
			array( array(
918
				'STS_ID' 					=> EEM_Registration::status_id_approved,
919
				'REG_deleted' 				=> 0,
920
				'Ticket.Datetime.DTT_ID' 	=> $this->ID(),
921
			) )
922
		);
923
        $sold = $this->sold();
924
        if ($count_regs_for_this_datetime > $sold) {
925
            $this->increase_sold($count_regs_for_this_datetime - $sold);
926
            $this->save();
927
        } else if ($count_regs_for_this_datetime < $sold) {
928
            $this->decrease_sold($count_regs_for_this_datetime - $sold);
929
            $this->save();
930
        }
931
		return $count_regs_for_this_datetime;
932
	}
933
}
934
935
/* End of file EE_Datetime.class.php */

core/db_classes/EE_Ticket.class.php 1 location

@@ 1290-1308 (lines=19) @@
1287
     * @return int
1288
     * @throws \EE_Error
1289
     */
1290
	public function update_tickets_sold() {
1291
        $count_regs_for_this_ticket = $this->count_registrations(
1292
            array(
1293
                array(
1294
                    'STS_ID'      => EEM_Registration::status_id_approved,
1295
                    'REG_deleted' => 0,
1296
                ),
1297
            )
1298
        );
1299
        $sold = $this->sold();
1300
        if ($count_regs_for_this_ticket > $sold) {
1301
            $this->increase_sold($count_regs_for_this_ticket - $sold);
1302
            $this->save();
1303
        } else if ($count_regs_for_this_ticket < $sold) {
1304
            $this->decrease_sold($count_regs_for_this_ticket - $sold);
1305
            $this->save();
1306
        }
1307
		return $count_regs_for_this_ticket;
1308
	}
1309
1310
1311