Skip to content
Snippets Groups Projects
Verified Commit 57b7b57f authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

refactor: remove PluginHeaderData


This class might become a decorator for `HeaderParser`, but at this
moment our functionality is implemented within `PluginInit` class
without loosing to much readability.

Signed-off-by: default avatarBart Jaskulski <bjaskulski@protonmail.com>
parent 597aa672
No related branches found
No related tags found
3 merge requests!3improve into wp-hook and some additional unfinished things,!21.x,!1Draft: Basic implementation of plugin initializer
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
<?php
declare( strict_types=1 );
namespace WPDesk\Init;
use WPDesk\Init\Configuration\ReadableConfig;
use WPDesk\Init\Dumper\PhpFileDumper;
use WPDesk\Init\Loader\PhpFileLoader;
class PluginHeaderData {
/** @var PluginHeaderParser */
private $parser;
/** @var PhpFileLoader */
private $loader;
/** @var PhpFileDumper */
private $dumper;
/** @var ReadableConfig */
private $config;
public function __construct(
PluginHeaderParser $parser,
PhpFileLoader $loader,
PhpFileDumper $dumper,
ReadableConfig $config
) {
$this->parser = $parser;
$this->loader = $loader;
$this->dumper = $dumper;
$this->config = $config;
}
public function get_plugin_data( string $plugin_file ): array {
$cache_path = $this->config->get( 'cache_path', 'generated' ) . '/plugin.php';
try {
return $this->loader->load( $cache_path );
} catch ( \Exception $e ) {
$plugin_data = $this->parser->parse( $plugin_file );
$this->dumper->dump( $plugin_data, $cache_path );
return $this->loader->load( $cache_path );
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment