Code Duplication    Length = 21-21 lines in 2 locations

classes/Pods.php 2 locations

@@ 2204-2224 (lines=21) @@
2201
				return 0;
2202
			}
2203
2204
			if ( isset( $params['orderby'] ) && ! empty( $params['orderby'] ) ) {
2205
				if ( is_array( $params['orderby'] ) ) {
2206
					foreach ( $params['orderby'] as $orderby => $dir ) {
2207
						$dir = strtoupper( $dir );
2208
2209
						if ( ! in_array( $dir, array( 'ASC', 'DESC' ), true ) ) {
2210
							continue;
2211
						}
2212
2213
						if ( 'ASC' === $dir ) {
2214
							$params['orderby'][ $orderby ] = 'DESC';
2215
						} else {
2216
							$params['orderby'][ $orderby ] = 'ASC';
2217
						}
2218
					}
2219
2220
					$params['orderby'][ $this->data->field_id ] = 'DESC';
2221
				} elseif ( "`t`.`{$this->data->field_id}` DESC" !== $params['orderby'] ) {
2222
					$params['orderby'] .= ", `t`.`{$this->data->field_id}` DESC";
2223
				}
2224
			}//end if
2225
2226
			$params['select'] = "`t`.`{$this->data->field_id}`";
2227
			$params['limit']  = 1;
@@ 2390-2410 (lines=21) @@
2387
				$params['offset'] = $this->total_found() - 1;
2388
			}
2389
2390
			if ( isset( $params['orderby'] ) && ! empty( $params['orderby'] ) ) {
2391
				if ( is_array( $params['orderby'] ) ) {
2392
					foreach ( $params['orderby'] as $orderby => $dir ) {
2393
						$dir = strtoupper( $dir );
2394
2395
						if ( ! in_array( $dir, array( 'ASC', 'DESC' ), true ) ) {
2396
							continue;
2397
						}
2398
2399
						if ( 'ASC' === $dir ) {
2400
							$params['orderby'][ $orderby ] = 'DESC';
2401
						} else {
2402
							$params['orderby'][ $orderby ] = 'ASC';
2403
						}
2404
					}
2405
2406
					$params['orderby'][ $this->data->field_id ] = 'DESC';
2407
				} elseif ( "`t`.`{$this->data->field_id}` DESC" !== $params['orderby'] ) {
2408
					$params['orderby'] .= ", `t`.`{$this->data->field_id}` DESC";
2409
				}
2410
			}//end if
2411
2412
			$params['select'] = "`t`.`{$this->data->field_id}`";
2413
			$params['limit']  = 1;