Code Duplication    Length = 21-21 lines in 2 locations

classes/Pods.php 2 locations

@@ 2218-2238 (lines=21) @@
2215
				return 0;
2216
			}
2217
2218
			if ( isset( $params['orderby'] ) && ! empty( $params['orderby'] ) ) {
2219
				if ( is_array( $params['orderby'] ) ) {
2220
					foreach ( $params['orderby'] as $orderby => $dir ) {
2221
						$dir = strtoupper( $dir );
2222
2223
						if ( ! in_array( $dir, array( 'ASC', 'DESC' ), true ) ) {
2224
							continue;
2225
						}
2226
2227
						if ( 'ASC' === $dir ) {
2228
							$params['orderby'][ $orderby ] = 'DESC';
2229
						} else {
2230
							$params['orderby'][ $orderby ] = 'ASC';
2231
						}
2232
					}
2233
2234
					$params['orderby'][ $this->data->field_id ] = 'DESC';
2235
				} elseif ( "`t`.`{$this->data->field_id}` DESC" !== $params['orderby'] ) {
2236
					$params['orderby'] .= ", `t`.`{$this->data->field_id}` DESC";
2237
				}
2238
			}//end if
2239
2240
			$params['select'] = "`t`.`{$this->data->field_id}`";
2241
			$params['limit']  = 1;
@@ 2404-2424 (lines=21) @@
2401
				$params['offset'] = $this->total_found() - 1;
2402
			}
2403
2404
			if ( isset( $params['orderby'] ) && ! empty( $params['orderby'] ) ) {
2405
				if ( is_array( $params['orderby'] ) ) {
2406
					foreach ( $params['orderby'] as $orderby => $dir ) {
2407
						$dir = strtoupper( $dir );
2408
2409
						if ( ! in_array( $dir, array( 'ASC', 'DESC' ), true ) ) {
2410
							continue;
2411
						}
2412
2413
						if ( 'ASC' === $dir ) {
2414
							$params['orderby'][ $orderby ] = 'DESC';
2415
						} else {
2416
							$params['orderby'][ $orderby ] = 'ASC';
2417
						}
2418
					}
2419
2420
					$params['orderby'][ $this->data->field_id ] = 'DESC';
2421
				} elseif ( "`t`.`{$this->data->field_id}` DESC" !== $params['orderby'] ) {
2422
					$params['orderby'] .= ", `t`.`{$this->data->field_id}` DESC";
2423
				}
2424
			}//end if
2425
2426
			$params['select'] = "`t`.`{$this->data->field_id}`";
2427
			$params['limit']  = 1;