Code Duplication    Length = 18-19 lines in 2 locations

core/db_classes/EE_Datetime.class.php 1 location

@@ 939-956 (lines=18) @@
936
     * @return int
937
     * @throws \EE_Error
938
     */
939
	public function update_sold() {
940
		$count_regs_for_this_datetime = EEM_Registration::instance()->count(
941
			array( array(
942
				'STS_ID' 					=> EEM_Registration::status_id_approved,
943
				'REG_deleted' 				=> 0,
944
				'Ticket.Datetime.DTT_ID' 	=> $this->ID(),
945
			) )
946
		);
947
        $sold = $this->sold();
948
        if ($count_regs_for_this_datetime > $sold) {
949
            $this->increase_sold($count_regs_for_this_datetime - $sold);
950
            $this->save();
951
        } else if ($count_regs_for_this_datetime < $sold) {
952
            $this->decrease_sold($count_regs_for_this_datetime - $sold);
953
            $this->save();
954
        }
955
		return $count_regs_for_this_datetime;
956
	}
957
}
958
959
/* End of file EE_Datetime.class.php */

core/db_classes/EE_Ticket.class.php 1 location

@@ 1314-1332 (lines=19) @@
1311
     * @return int
1312
     * @throws \EE_Error
1313
     */
1314
	public function update_tickets_sold() {
1315
        $count_regs_for_this_ticket = $this->count_registrations(
1316
            array(
1317
                array(
1318
                    'STS_ID'      => EEM_Registration::status_id_approved,
1319
                    'REG_deleted' => 0,
1320
                ),
1321
            )
1322
        );
1323
        $sold = $this->sold();
1324
        if ($count_regs_for_this_ticket > $sold) {
1325
            $this->increase_sold($count_regs_for_this_ticket - $sold);
1326
            $this->save();
1327
        } else if ($count_regs_for_this_ticket < $sold) {
1328
            $this->decrease_sold($count_regs_for_this_ticket - $sold);
1329
            $this->save();
1330
        }
1331
		return $count_regs_for_this_ticket;
1332
	}
1333
1334
1335