Completed
Push — fix/autoloader-inclusion ( 97665e )
by
unknown
163:34 queued 153:07
created

autoload_functions.php ➔ autoloader()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 14
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file was automatically generated by automattic/jetpack-autoloader.
4
 *
5
 * @package automattic/jetpack-autoloader
6
 */
7
8
namespace Automattic\Jetpack\Autoloader\jp95016e8b7af5cfd6a3cbf90d4433a769;
9
10
 // phpcs:ignore
11
12
/**
13
 * Used for autoloading jetpack packages.
14
 *
15
 * @param string $class_name Class Name to load.
16
 *
17
 * @return Boolean Whether the class_name was found in the classmap.
18
 */
19 View Code Duplication
function autoloader( $class_name ) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
	global $jetpack_autoloader_loader;
21
	if ( ! isset( $jetpack_autoloader_loader ) ) {
22
		return false;
23
	}
24
25
	$file = $jetpack_autoloader_loader->find_class_file( $class_name );
26
	if ( ! isset( $file ) ) {
27
		return false;
28
	}
29
30
	require_once $file;
31
	return true;
32
}
33
34
/**
35
 * Finds the latest installed autoloader. If this is the latest autoloader, sets
36
 * up the classmap and filemap.
37
 */
38
function set_up_autoloader() {
39
	global $jetpack_autoloader_latest_version;
40
	global $jetpack_autoloader_loader;
41
42
	require_once __DIR__ . '/class-plugins-handler.php';
43
	require_once __DIR__ . '/class-version-selector.php';
44
	require_once __DIR__ . '/class-autoloader-locator.php';
45
	require_once __DIR__ . '/class-autoloader-handler.php';
46
47
	$plugins_handler    = new Plugins_Handler();
48
	$version_selector   = new Version_Selector();
49
	$autoloader_handler = new Autoloader_Handler(
50
		$plugins_handler->get_current_plugin_path(),
51
		$plugins_handler->get_all_active_plugins_paths(),
52
		new Autoloader_Locator( $version_selector ),
53
		$version_selector
54
	);
55
56
	// The autoloader must be reset when a plugin that was previously unknown is detected.
57
	if ( $autoloader_handler->should_autoloader_reset() ) {
58
		$jetpack_autoloader_latest_version = null;
59
		$jetpack_autoloader_loader         = null;
60
	}
61
62
	if ( ! $autoloader_handler->is_latest_autoloader() || isset( $jetpack_autoloader_loader ) ) {
63
		return;
64
	}
65
66
	require_once __DIR__ . '/class-manifest-handler.php';
67
	require_once __DIR__ . '/class-version-loader.php';
68
69
	$jetpack_autoloader_loader = $autoloader_handler->build_autoloader();
70
	$autoloader_handler->update_autoloader_chain();
71
72
	// Now that the autoloader is ready we can load the files in the filemap safely.
73
	$jetpack_autoloader_loader->load_filemap();
74
}
75