Code Duplication    Length = 11-11 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1562-1572 (lines=11) @@
1559
		}
1560
1561
		static $matches;
1562
		if ( empty( $matches ) ) {
1563
			$matches = array();
1564
		} else {
1565
			// try to match out of saved matches
1566
			foreach( $matches as $match ) {
1567
				$regex = $match->regex;
1568
				if ( preg_match( "#^$regex\$#", $path ) ) {
1569
					return $match->version;
1570
				}
1571
			}
1572
		}
1573
1574
		$endpoint_path_versions = $this->get_endpoint_path_versions();
1575
		$last_path_segment = $this->get_last_segment_of_relative_path( $path );

sal/class.json-api-links.php 1 location

@@ 145-155 (lines=11) @@
142
		}
143
144
		static $matches;
145
		if ( empty( $matches ) ) {
146
			$matches = array();
147
		} else {
148
			// try to match out of saved matches
149
			foreach( $matches as $match ) {
150
				$regex = $match->regex;
151
				if ( preg_match( "#^$regex\$#", $path ) ) {
152
					return $closest_endpoint_cache[ $template_path ][ $request_method ] = $match->version;
153
				}
154
			}
155
		}
156
157
		$endpoint_path_versions = $this->get_endpoint_path_versions();
158
		$last_path_segment = $this->get_last_segment_of_relative_path( $path );