Code Duplication    Length = 29-29 lines in 2 locations

classes/Pods.php 2 locations

@@ 1983-2011 (lines=29) @@
1980
				$value = explode( ',', $value );
1981
			}
1982
1983
			if ( 'pick' === $this->fields[ $field ]['type'] && in_array( $this->fields[ $field ]['pick_object'], PodsForm::simple_tableless_objects(), true ) ) {
1984
				$current_value = $pod->raw( $field );
1985
1986
				if ( ! empty( $current_value ) ) {
1987
					$current_value = (array) $current_value;
1988
				}
1989
1990
				foreach ( $current_value as $v ) {
1991
					// @codingStandardsIgnoreLine.
1992
					if ( in_array( $v, $value ) ) {
1993
						return true;
1994
					}
1995
				}
1996
			} else {
1997
				$related_ids = $this->api->lookup_related_items( $this->fields[ $field ]['id'], $this->pod_data['id'], $id, $this->fields[ $field ], $this->pod_data );
1998
1999
				foreach ( $value as $k => $v ) {
2000
					if ( ! preg_match( '/[^\D]/', $v ) ) {
2001
						$value[ $k ] = (int) $v;
2002
					}
2003
2004
					// @todo Convert slugs into IDs.
2005
				}
2006
2007
				foreach ( $related_ids as $v ) {
2008
					// @codingStandardsIgnoreLine.
2009
					if ( in_array( $v, $value ) ) {
2010
						return true;
2011
					}
2012
				}
2013
			}//end if
2014
		} elseif ( in_array( $this->fields[ $field ]['type'], PodsForm::text_field_types(), true ) ) {
@@ 2065-2093 (lines=29) @@
2062
2063
			$current_value = array();
2064
2065
			if ( 'pick' === $this->fields[ $field ]['type'] && in_array( $this->fields[ $field ]['pick_object'], PodsForm::simple_tableless_objects(), true ) ) {
2066
				$current_value = $pod->raw( $field );
2067
2068
				if ( ! empty( $current_value ) ) {
2069
					$current_value = (array) $current_value;
2070
				}
2071
2072
				foreach ( $current_value as $v ) {
2073
					// @codingStandardsIgnoreLine.
2074
					if ( in_array( $v, $value ) ) {
2075
						return true;
2076
					}
2077
				}
2078
			} else {
2079
				$related_ids = $this->api->lookup_related_items( $this->fields[ $field ]['id'], $this->pod_data['id'], $id, $this->fields[ $field ], $this->pod_data );
2080
2081
				foreach ( $value as $k => $v ) {
2082
					if ( ! preg_match( '/[^\D]/', $v ) ) {
2083
						$value[ $k ] = (int) $v;
2084
					}
2085
2086
					// @todo Convert slugs into IDs.
2087
				}
2088
2089
				foreach ( $related_ids as $v ) {
2090
					// @codingStandardsIgnoreLine.
2091
					if ( in_array( $v, $value ) ) {
2092
						return true;
2093
					}
2094
				}
2095
			}//end if
2096