Code Duplication    Length = 16-16 lines in 2 locations

packages/autoloader/src/class-path-processor.php 2 locations

@@ 14-29 (lines=16) @@
11
	 * @param string $path The path we want to process.
12
	 * @return string The tokenized path.
13
	 */
14
	public function tokenize_path_constants( $path ) {
15
		$path = self::normalize( $path );
16
17
		$constants = self::get_path_constants();
18
		foreach ( $constants as $constant => $constant_path ) {
19
			$len = strlen( $constant_path );
20
			if ( substr( $path, 0, $len ) !== $constant_path ) {
21
				continue;
22
			}
23
24
			$path = substr_replace( $path, '{{' . $constant . '}}', 0, $len );
25
			break;
26
		}
27
28
		return $path;
29
	}
30
31
	/**
32
	 * Given a path this will replace any of the path constant tokens with the expanded path.
@@ 37-52 (lines=16) @@
34
	 * @param string $path The path we want to process.
35
	 * @return string The expanded path.
36
	 */
37
	public function untokenize_path_constants( $path ) {
38
		$constants = self::get_path_constants();
39
		foreach ( $constants as $constant => $constant_path ) {
40
			$constant = '{{' . $constant . '}}';
41
42
			$len = strlen( $constant );
43
			if ( substr( $path, 0, $len ) !== $constant ) {
44
				continue;
45
			}
46
47
			$path = substr_replace( $path, $constant_path, 0, $len );
48
			break;
49
		}
50
51
		return $path;
52
	}
53
54
	/**
55
	 * Given a file and an array of places it might be, this will find the absolute path and return it.