Code Duplication    Length = 18-19 lines in 4 locations

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

@@ 88-106 (lines=19) @@
85
     * @throws InvalidInterfaceException
86
     * @throws RestException
87
     */
88
    public function registrationsCheckedInCount($wpdb_row, $request, $controller)
89
    {
90
        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
91
            throw new EE_Error(
92
                sprintf(
93
                    __(
94
                    // @codingStandardsIgnoreStart
95
                        'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
96
                        // @codingStandardsIgnoreEnd
97
                        'event_espresso'
98
                    ),
99
                    print_r($wpdb_row, true)
100
                )
101
            );
102
        }
103
        $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count');
104
        return $this->registration_model
105
                               ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true);
106
    }
107
108
109
    /**
@@ 122-140 (lines=19) @@
119
     * @throws InvalidInterfaceException
120
     * @throws RestException
121
     */
122
    public function registrationsCheckedOutCount($wpdb_row, $request, $controller)
123
    {
124
        if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) {
125
            throw new EE_Error(
126
                sprintf(
127
                    __(
128
                    // @codingStandardsIgnoreStart
129
                        'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"',
130
                        // @codingStandardsIgnoreEnd
131
                        'event_espresso'
132
                    ),
133
                    print_r($wpdb_row, true)
134
                )
135
            );
136
        }
137
        $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count');
138
        return $this->registration_model
139
                               ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false);
140
    }
141
142
143
    /**

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

@@ 261-278 (lines=18) @@
258
     * @throws InvalidInterfaceException
259
     * @throws RestException
260
     */
261
    public function registrationsCheckedInCount($wpdb_row, $request, $controller)
262
    {
263
        if (! Event::wpdbRowHasEventId($wpdb_row)) {
264
            throw new EE_Error(
265
                sprintf(
266
                    __(
267
                    // @codingStandardsIgnoreStart
268
                        'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"',
269
                        // @codingStandardsIgnoreEnd
270
                        'event_espresso'
271
                    ),
272
                    print_r($wpdb_row, true)
273
                )
274
            );
275
        }
276
        $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count');
277
        return $this->registration_model->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true);
278
    }
279
280
281
    /**
@@ 295-312 (lines=18) @@
292
     * @throws InvalidInterfaceException
293
     * @throws RestException
294
     */
295
    public function registrationsCheckedOutCount($wpdb_row, $request, $controller)
296
    {
297
        if (! Event::wpdbRowHasEventId($wpdb_row)) {
298
            throw new EE_Error(
299
                sprintf(
300
                    __(
301
                    // @codingStandardsIgnoreStart
302
                        'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"',
303
                        // @codingStandardsIgnoreEnd
304
                        'event_espresso'
305
                    ),
306
                    print_r($wpdb_row, true)
307
                )
308
            );
309
        }
310
        $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count');
311
        return $this->registration_model->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false);
312
    }
313
314
315
    /**