Code Duplication    Length = 29-29 lines in 2 locations

classes/Pods.php 2 locations

@@ 1961-1989 (lines=29) @@
1958
				$value = explode( ',', $value );
1959
			}
1960
1961
			if ( 'pick' === $this->fields[ $field ]['type'] && in_array( $this->fields[ $field ]['pick_object'], PodsForm::simple_tableless_objects(), true ) ) {
1962
				$current_value = $pod->raw( $field );
1963
1964
				if ( ! empty( $current_value ) ) {
1965
					$current_value = (array) $current_value;
1966
				}
1967
1968
				foreach ( $current_value as $v ) {
1969
					if ( in_array( $v, $value ) ) {
1970
						return true;
1971
					}
1972
				}
1973
			} else {
1974
				$related_ids = $this->api->lookup_related_items( $this->fields[ $field ]['id'], $this->pod_data['id'], $id, $this->fields[ $field ], $this->pod_data );
1975
1976
				foreach ( $value as $k => $v ) {
1977
					if ( ! preg_match( '/[^\D]/', $v ) ) {
1978
						$value[ $k ] = (int) $v;
1979
					}
1980
1981
					// @todo Convert slugs into IDs
1982
				}
1983
1984
				foreach ( $related_ids as $v ) {
1985
					if ( in_array( $v, $value ) ) {
1986
						return true;
1987
					}
1988
				}
1989
			}
1990
		} // Text fields
1991
		elseif ( in_array( $this->fields[ $field ]['type'], PodsForm::text_field_types(), true ) ) {
1992
			$current_value = $pod->raw( $field );
@@ 2040-2068 (lines=29) @@
2037
2038
			$current_value = array();
2039
2040
			if ( 'pick' === $this->fields[ $field ]['type'] && in_array( $this->fields[ $field ]['pick_object'], PodsForm::simple_tableless_objects(), true ) ) {
2041
				$current_value = $pod->raw( $field );
2042
2043
				if ( ! empty( $current_value ) ) {
2044
					$current_value = (array) $current_value;
2045
				}
2046
2047
				foreach ( $current_value as $v ) {
2048
					if ( in_array( $v, $value ) ) {
2049
						return true;
2050
					}
2051
				}
2052
			} else {
2053
				$related_ids = $this->api->lookup_related_items( $this->fields[ $field ]['id'], $this->pod_data['id'], $id, $this->fields[ $field ], $this->pod_data );
2054
2055
				foreach ( $value as $k => $v ) {
2056
					if ( ! preg_match( '/[^\D]/', $v ) ) {
2057
						$value[ $k ] = (int) $v;
2058
					}
2059
2060
					// @todo Convert slugs into IDs
2061
				}
2062
2063
				foreach ( $related_ids as $v ) {
2064
					if ( in_array( $v, $value ) ) {
2065
						return true;
2066
					}
2067
				}
2068
			}
2069
2070
			if ( ! empty( $current_value ) ) {
2071
				$current_value = array_filter( array_unique( $current_value ) );