Code Duplication    Length = 29-29 lines in 2 locations

classes/Pods.php 2 locations

@@ 1969-1997 (lines=29) @@
1966
				$value = explode( ',', $value );
1967
			}
1968
1969
			if ( 'pick' === $this->fields[ $field ]['type'] && in_array( $this->fields[ $field ]['pick_object'], PodsForm::simple_tableless_objects(), true ) ) {
1970
				$current_value = $pod->raw( $field );
1971
1972
				if ( ! empty( $current_value ) ) {
1973
					$current_value = (array) $current_value;
1974
				}
1975
1976
				foreach ( $current_value as $v ) {
1977
					// @codingStandardsIgnoreLine.
1978
					if ( in_array( $v, $value ) ) {
1979
						return true;
1980
					}
1981
				}
1982
			} else {
1983
				$related_ids = $this->api->lookup_related_items( $this->fields[ $field ]['id'], $this->pod_data['id'], $id, $this->fields[ $field ], $this->pod_data );
1984
1985
				foreach ( $value as $k => $v ) {
1986
					if ( ! preg_match( '/[^\D]/', $v ) ) {
1987
						$value[ $k ] = (int) $v;
1988
					}
1989
1990
					// @todo Convert slugs into IDs.
1991
				}
1992
1993
				foreach ( $related_ids as $v ) {
1994
					// @codingStandardsIgnoreLine.
1995
					if ( in_array( $v, $value ) ) {
1996
						return true;
1997
					}
1998
				}
1999
			}//end if
2000
		} elseif ( in_array( $this->fields[ $field ]['type'], PodsForm::text_field_types(), true ) ) {
@@ 2051-2079 (lines=29) @@
2048
2049
			$current_value = array();
2050
2051
			if ( 'pick' === $this->fields[ $field ]['type'] && in_array( $this->fields[ $field ]['pick_object'], PodsForm::simple_tableless_objects(), true ) ) {
2052
				$current_value = $pod->raw( $field );
2053
2054
				if ( ! empty( $current_value ) ) {
2055
					$current_value = (array) $current_value;
2056
				}
2057
2058
				foreach ( $current_value as $v ) {
2059
					// @codingStandardsIgnoreLine.
2060
					if ( in_array( $v, $value ) ) {
2061
						return true;
2062
					}
2063
				}
2064
			} else {
2065
				$related_ids = $this->api->lookup_related_items( $this->fields[ $field ]['id'], $this->pod_data['id'], $id, $this->fields[ $field ], $this->pod_data );
2066
2067
				foreach ( $value as $k => $v ) {
2068
					if ( ! preg_match( '/[^\D]/', $v ) ) {
2069
						$value[ $k ] = (int) $v;
2070
					}
2071
2072
					// @todo Convert slugs into IDs.
2073
				}
2074
2075
				foreach ( $related_ids as $v ) {
2076
					// @codingStandardsIgnoreLine.
2077
					if ( in_array( $v, $value ) ) {
2078
						return true;
2079
					}
2080
				}
2081
			}//end if
2082