Skip to content
Snippets Groups Projects

Draft: Basic implementation of plugin initializer

Closed Bartek Jaskulski requested to merge 1.x into review
2 unresolved threads
1 file
+ 7
2
Compare changes
  • Side-by-side
  • Inline
<?php
declare( strict_types=1 );
namespace WPDesk\Init\Loader;
class PhpFileLoader {
/**
* @param string|Path $resource
*
* @return mixed
*/
public function load( $resource ) {
// TODO: add file locator
return ( static function () use ( $resource ) {
if ( ! is_readable( (string) $resource ) ) {
throw new \RuntimeException( "Could not load $resource" );
}
$data = include (string) $resource;
if ( $data === false ) {
throw new \RuntimeException( "Could not load $resource" );
}
return $data;
} )();
}
}
Loading