Code Duplication    Length = 15-18 lines in 4 locations

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

@@ 76-90 (lines=15) @@
73
     * @throws \EE_Error
74
     * @throws \EventEspresso\core\libraries\rest_api\RestException
75
     */
76
    public static function registrationsCheckedInCount($wpdb_row, $request, $controller)
77
    {
78
        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
79
            throw new \EE_Error(
80
                sprintf(
81
                    __(
82
                        // @codingStandardsIgnoreStart
83
                        'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
84
                        // @codingStandardsIgnoreEnd
85
                        'event_espresso'
86
                    ),
87
                    print_r($wpdb_row, true)
88
                )
89
            );
90
        }
91
        self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count');
92
        return EEM_Registration::instance()
93
                                ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true);
@@ 108-122 (lines=15) @@
105
     * @throws \EE_Error
106
     * @throws \EventEspresso\core\libraries\rest_api\RestException
107
     */
108
    public static function registrationsCheckedOutCount($wpdb_row, $request, $controller)
109
    {
110
        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
111
            throw new \EE_Error(
112
                sprintf(
113
                    __(
114
                        // @codingStandardsIgnoreStart
115
                        'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
116
                        // @codingStandardsIgnoreEnd
117
                        'event_espresso'
118
                    ),
119
                    print_r($wpdb_row, true)
120
                )
121
            );
122
        }
123
        self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count');
124
        return EEM_Registration::instance()
125
                                ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false);

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

@@ 228-245 (lines=18) @@
225
     * @throws EE_Error
226
     * @throws RestException
227
     */
228
    public static function registrationsCheckedInCount($wpdb_row, $request, $controller)
229
    {
230
        if (! Event::wpdbRowHasEventId($wpdb_row)) {
231
            throw new EE_Error(
232
                sprintf(
233
                    __(
234
                        // @codingStandardsIgnoreStart
235
                        'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"',
236
                        // @codingStandardsIgnoreEnd
237
                        'event_espresso'
238
                    ),
239
                    print_r($wpdb_row, true)
240
                )
241
            );
242
        }
243
        self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count');
244
        return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true);
245
    }
246
247
248
@@ 260-277 (lines=18) @@
257
     * @throws EE_Error
258
     * @throws RestException
259
     */
260
    public static function registrationsCheckedOutCount($wpdb_row, $request, $controller)
261
    {
262
        if (! Event::wpdbRowHasEventId($wpdb_row)) {
263
            throw new EE_Error(
264
                sprintf(
265
                    __(
266
                        // @codingStandardsIgnoreStart
267
                        'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"',
268
                        // @codingStandardsIgnoreEnd
269
                        'event_espresso'
270
                    ),
271
                    print_r($wpdb_row, true)
272
                )
273
            );
274
        }
275
        self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count');
276
        return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false);
277
    }
278
279
280