PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.0
1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / vendor / automattic / jetpack-autoloader / src / ManifestGenerator.php
hostinger-reach / vendor / automattic / jetpack-autoloader / src Last commit date
AutoloadFileWriter.php 7 months ago AutoloadGenerator.php 1 month ago AutoloadProcessor.php 1 year ago CustomAutoloaderPlugin.php 1 month ago ManifestGenerator.php 1 year ago autoload.php 1 year ago class-autoloader-handler.php 1 year ago class-autoloader-locator.php 1 year ago class-autoloader.php 1 year ago class-container.php 1 year ago class-hook-manager.php 1 year ago class-latest-autoloader-guard.php 1 year ago class-manifest-reader.php 1 year ago class-path-processor.php 1 year ago class-php-autoloader.php 1 year ago class-plugin-locator.php 1 year ago class-plugins-handler.php 1 year ago class-shutdown-handler.php 1 year ago class-version-loader.php 1 year ago class-version-selector.php 1 year ago
ManifestGenerator.php
116 lines
1 <?php
2 /**
3 * Manifest Generator.
4 *
5 * @package automattic/jetpack-autoloader
6 */
7
8 // phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_var_export
9
10 namespace Automattic\Jetpack\Autoloader;
11
12 /**
13 * Class ManifestGenerator.
14 */
15 class ManifestGenerator {
16
17 /**
18 * Builds a manifest file for the given autoloader type.
19 *
20 * @param string $autoloaderType The type of autoloader to build a manifest for.
21 * @param string $fileName The filename of the manifest.
22 * @param array $content The manifest content to generate using.
23 *
24 * @return string|null $manifestFile
25 * @throws \InvalidArgumentException When an invalid autoloader type is given.
26 */
27 public static function buildManifest( $autoloaderType, $fileName, $content ) {
28 if ( empty( $content ) ) {
29 return null;
30 }
31
32 switch ( $autoloaderType ) {
33 case 'classmap':
34 case 'files':
35 return self::buildStandardManifest( $fileName, $content );
36 case 'psr-4':
37 return self::buildPsr4Manifest( $fileName, $content );
38 }
39
40 throw new \InvalidArgumentException( 'An invalid manifest type of ' . $autoloaderType . ' was passed!' );
41 }
42
43 /**
44 * Builds the contents for the standard manifest file.
45 *
46 * @param string $fileName The filename we are building.
47 * @param array $manifestData The formatted data for the manifest.
48 *
49 * @return string|null $manifestFile
50 */
51 private static function buildStandardManifest( $fileName, $manifestData ) {
52 $fileContent = PHP_EOL;
53 foreach ( $manifestData as $key => $data ) {
54 $key = var_export( $key, true );
55 $versionCode = var_export( $data['version'], true );
56 $fileContent .= <<<MANIFEST_CODE
57 $key => array(
58 'version' => $versionCode,
59 'path' => {$data['path']}
60 ),
61 MANIFEST_CODE;
62 $fileContent .= PHP_EOL;
63 }
64
65 return self::buildFile( $fileName, $fileContent );
66 }
67
68 /**
69 * Builds the contents for the PSR-4 manifest file.
70 *
71 * @param string $fileName The filename we are building.
72 * @param array $namespaces The formatted PSR-4 data for the manifest.
73 *
74 * @return string|null $manifestFile
75 */
76 private static function buildPsr4Manifest( $fileName, $namespaces ) {
77 $fileContent = PHP_EOL;
78 foreach ( $namespaces as $namespace => $data ) {
79 $namespaceCode = var_export( $namespace, true );
80 $versionCode = var_export( $data['version'], true );
81 $pathCode = 'array( ' . implode( ', ', $data['path'] ) . ' )';
82 $fileContent .= <<<MANIFEST_CODE
83 $namespaceCode => array(
84 'version' => $versionCode,
85 'path' => $pathCode
86 ),
87 MANIFEST_CODE;
88 $fileContent .= PHP_EOL;
89 }
90
91 return self::buildFile( $fileName, $fileContent );
92 }
93
94 /**
95 * Generate the PHP that will be used in the file.
96 *
97 * @param string $fileName The filename we are building.
98 * @param string $content The content to be written into the file.
99 *
100 * @return string $fileContent
101 */
102 private static function buildFile( $fileName, $content ) {
103 return <<<INCLUDE_FILE
104 <?php
105
106 // This file `$fileName` was auto generated by automattic/jetpack-autoloader.
107
108 \$vendorDir = dirname(__DIR__);
109 \$baseDir = dirname(\$vendorDir);
110
111 return array($content);
112
113 INCLUDE_FILE;
114 }
115 }
116