Skip to content

Commit bd99c91

Browse files
committed
load from base64
1 parent 1e0e85f commit bd99c91

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/Loader.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class Loader
1414
/**
1515
* @return null|LoaderInterface
1616
*/
17-
public static function load(string $path, ?string $loaderPath = null)
17+
public static function load(string $path, ?string $encodedLoader = null)
1818
{
19-
if ($loaderPath !== null) {
20-
$loaderClass = self::getLoaderClassFromPath($loaderPath);
19+
if ($encodedLoader !== null) {
20+
$loaderClass = self::getLoaderClassFrom($encodedLoader);
2121

2222
if ($loaderClass !== null) {
2323
return new $loaderClass($path);
@@ -47,20 +47,13 @@ public static function load(string $path, ?string $loaderPath = null)
4747
return null;
4848
}
4949

50-
private static function getLoaderClassFromPath(string $path)
50+
private static function getLoaderClassFrom(string $encodedLoader)
5151
{
52-
if (! file_exists($path)) {
53-
return null;
54-
}
55-
5652
$declaredClassesBefore = get_declared_classes();
57-
58-
require_once $path;
59-
53+
$loader = base64_decode($encodedLoader);
54+
eval(str_replace('<?php', '', $loader));
6055
$declaredClassesAfter = get_declared_classes();
61-
6256
$newClasses = array_diff($declaredClassesAfter, $declaredClassesBefore);
63-
6457
if (empty($newClasses)) {
6558
return null;
6659
}

src/Loaders/BaseLoader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@ public function casters(): array
4141
{
4242
return [];
4343
}
44+
45+
public static function supports(string $path): bool
46+
{
47+
return false;
48+
}
4449
}

0 commit comments

Comments
 (0)