Skip to content

Commit e2e50b0

Browse files
authored
Merge pull request #5 from gander/feature/supports
feat: LoaderInterface::supports
2 parents 0826387 + 46c4d92 commit e2e50b0

File tree

6 files changed

+51
-13
lines changed

6 files changed

+51
-13
lines changed

src/Loader.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,19 @@ class Loader
1717
*/
1818
public static function load(string $path)
1919
{
20-
if (file_exists($path . '/vendor/autoload.php') && file_exists($path . '/bootstrap/app.php')) {
20+
if (LaravelLoader::supports($path)) {
2121
return new LaravelLoader($path);
2222
}
2323

24-
if (file_exists($path . '/vendor/autoload.php') && file_exists($path . '/symfony.lock') && file_exists($path . '/src/Kernel.php')) {
24+
if (SymfonyLoader::supports($path)) {
2525
return new SymfonyLoader($path);
2626
}
2727

28-
if (file_exists($path . '/wp-load.php')) {
28+
if (WordPressLoader::supports($path)) {
2929
return new WordPressLoader($path);
3030
}
3131

32-
if (file_exists($path . '/vendor/autoload.php') && file_exists($path . '/vendor/pimcore/pimcore')) {
33-
return new PimcoreLoader($path);
34-
}
35-
36-
if (file_exists($path . '/vendor/autoload.php')) {
32+
if (ComposerLoader::supports($path)) {
3733
return new ComposerLoader($path);
3834
}
3935

src/Loaders/ComposerLoader.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
class ComposerLoader extends BaseLoader
66
{
7+
/**
8+
* @param string $path
9+
* @return bool
10+
*/
11+
public static function supports(string $path): bool
12+
{
13+
return file_exists($path . '/vendor/autoload.php');
14+
}
15+
716
/**
817
* @param string $path
918
*/
@@ -24,4 +33,4 @@ public function version(): string
2433
{
2534
return "";
2635
}
27-
}
36+
}

src/Loaders/LaravelLoader.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ class LaravelLoader extends ComposerLoader
88
{
99
private $app;
1010

11+
/**
12+
* @param string $path
13+
* @return bool
14+
*/
15+
public static function supports(string $path): bool
16+
{
17+
return file_exists($path . '/vendor/autoload.php') && file_exists($path . '/bootstrap/app.php');
18+
}
19+
1120
/**
1221
* @param string $path
1322
*/
@@ -47,4 +56,4 @@ public function version(): string
4756
{
4857
return $this->app->version();
4958
}
50-
}
59+
}

src/Loaders/LoaderInterface.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
interface LoaderInterface
66
{
7+
/**
8+
* @param string $path
9+
* @return bool
10+
*/
11+
public static function supports(string $path): bool;
12+
713
/**
814
* @return string
915
*/
@@ -24,4 +30,4 @@ public function init();
2430
* @return void
2531
*/
2632
public function execute(string $code);
27-
}
33+
}

src/Loaders/SymfonyLoader.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ class SymfonyLoader extends ComposerLoader
66
{
77
private $kernel;
88

9+
/**
10+
* @param string $path
11+
* @return bool
12+
*/
13+
public static function supports(string $path): bool
14+
{
15+
return file_exists($path . '/vendor/autoload.php') && file_exists($path . '/symfony.lock') && file_exists($path . '/src/Kernel.php');
16+
}
17+
918
/**
1019
* @param string $path
1120
*/
@@ -57,4 +66,4 @@ public function version(): string
5766
{
5867
return \Symfony\Component\HttpKernel\Kernel::VERSION;
5968
}
60-
}
69+
}

src/Loaders/WordPressLoader.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
class WordPressLoader extends BaseLoader
88
{
9+
/**
10+
* @param string $path
11+
* @return bool
12+
*/
13+
public static function supports(string $path): bool
14+
{
15+
return file_exists($path . '/wp-load.php');
16+
}
17+
918
/**
1019
* @param string $path
1120
*/
@@ -34,4 +43,4 @@ public function version(): string
3443

3544
return "";
3645
}
37-
}
46+
}

0 commit comments

Comments
 (0)