Code Duplication    Length = 26-27 lines in 2 locations

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

@@ 147-172 (lines=26) @@
144
     * @return int
145
     * @throws EE_Error
146
     */
147
    public static function spotsTaken($wpdb_row, $request, $controller)
148
    {
149
        if (! Event::wpdbRowHasEventId($wpdb_row)) {
150
            throw new EE_Error(
151
                sprintf(
152
                    __(
153
                        // @codingStandardsIgnoreStart
154
                        'Cannot calculate spots_taken because the database row %1$s does not have a valid entry for "Event_CPT.ID"',
155
                        // @codingStandardsIgnoreEnd
156
                        'event_espresso'
157
                    ),
158
                    print_r($wpdb_row, true)
159
                )
160
            );
161
        }
162
        return EEM_Registration::instance()->count(
163
            array(
164
                array(
165
                    'EVT_ID' => $wpdb_row['Event_CPT.ID'],
166
                    'STS_ID' => EEM_Registration::status_id_approved,
167
                ),
168
            ),
169
            'REG_ID',
170
            true
171
        );
172
    }
173
174
175
@@ 187-213 (lines=27) @@
184
     * @throws EE_Error
185
     * @throws RestException
186
     */
187
    public static function spotsTakenPendingPayment($wpdb_row, $request, $controller)
188
    {
189
        if (! Event::wpdbRowHasEventId($wpdb_row)) {
190
            throw new EE_Error(
191
                sprintf(
192
                    __(
193
                        // @codingStandardsIgnoreStart
194
                        'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"',
195
                        // @codingStandardsIgnoreEnd
196
                        'event_espresso'
197
                    ),
198
                    print_r($wpdb_row, true)
199
                )
200
            );
201
        }
202
        self::verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment');
203
        return EEM_Registration::instance()->count(
204
            array(
205
                array(
206
                    'EVT_ID' => $wpdb_row['Event_CPT.ID'],
207
                    'STS_ID' => EEM_Registration::status_id_pending_payment,
208
                ),
209
            ),
210
            'REG_ID',
211
            true
212
        );
213
    }
214
215
216