Skip to content
Snippets Groups Projects
Select Git revision
  • 611464c6669038d5130ee0f21a8fc64f876a6d5a
  • master default protected
  • feat/message-handling
  • feat/request-id
  • 1.13.2
  • 1.13.1
  • 1.13.0
  • 1.12.1
  • 1.12.0
  • 1.11.0
  • 1.11.0-beta2
  • 1.11.0-beta1
  • 1.10.2
  • 1.10.1
  • 1.10.0
  • 1.9.0
  • 1.8.0
  • 1.7.4
  • 1.7.3
  • 1.7.2
  • 1.7.1
  • 1.7.0
  • 1.6.2
  • 1.6.2-beta2
24 results

SensitiveDataProcessor.php

Blame
  • PluginHeaderData.php 1.02 KiB
    <?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 );
    		}
    	}
    
    }