Code Duplication    Length = 12-12 lines in 4 locations

core/libraries/rest_api/calculations/Datetime.php 2 locations

@@ 66-77 (lines=12) @@
63
	 * @throws \EE_Error
64
	 * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception
65
	 */
66
	public static function registrations_checked_in_count( $wpdb_row, $request, $controller ){
67
		if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Datetime.DTT_ID' ] ) ) {
68
			throw new \EE_Error(
69
				sprintf(
70
					__( 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', 'event_espresso' ),
71
					print_r( $wpdb_row, true )
72
				)
73
			);
74
		}
75
		self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_in_count' );
76
		return \EEM_Registration::instance()->count_registrations_checked_into_datetime( $wpdb_row[ 'Datetime.DTT_ID' ], true );
77
	}
78
79
80
@@ 91-102 (lines=12) @@
88
	 * @throws \EE_Error
89
	 * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception
90
	 */
91
	public static function registrations_checked_out_count( $wpdb_row, $request, $controller ){
92
		if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Datetime.DTT_ID' ] ) ) {
93
			throw new \EE_Error(
94
				sprintf(
95
					__( 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', 'event_espresso' ),
96
					print_r( $wpdb_row, true )
97
				)
98
			);
99
		}
100
		self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_out_count' );
101
		return \EEM_Registration::instance()->count_registrations_checked_into_datetime( $wpdb_row[ 'Datetime.DTT_ID' ], false );
102
	}
103
104
105

core/libraries/rest_api/calculations/Event.php 2 locations

@@ 198-209 (lines=12) @@
195
	 * @throws \EE_Error
196
	 * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception
197
	 */
198
	public static function registrations_checked_in_count( $wpdb_row, $request, $controller ){
199
		if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) {
200
			throw new \EE_Error(
201
				sprintf(
202
					__( 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ),
203
					print_r( $wpdb_row, true )
204
				)
205
			);
206
		}
207
		self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_in_count' );
208
		return \EEM_Registration::instance()->count_registrations_checked_into_event( $wpdb_row[ 'Event_CPT.ID' ], true );
209
	}
210
211
212
@@ 224-235 (lines=12) @@
221
	 * @throws \EE_Error
222
	 * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception
223
	 */
224
	public static function registrations_checked_out_count( $wpdb_row, $request, $controller ){
225
		if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) {
226
			throw new \EE_Error(
227
				sprintf(
228
					__( 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ),
229
					print_r( $wpdb_row, true )
230
				)
231
			);
232
		}
233
		self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_out_count' );
234
		return \EEM_Registration::instance()->count_registrations_checked_into_event( $wpdb_row[ 'Event_CPT.ID' ], false );
235
	}
236
237
	/**
238
	 * Gets the thumbnail image