diff --git a/src/RuleLoader.php b/src/RuleLoader.php new file mode 100644 index 0000000..6fcab2c --- /dev/null +++ b/src/RuleLoader.php @@ -0,0 +1,32 @@ +make('config')['arkitect']; + + return Arr::flatten($package_config['rules']); + } + + public static function all(): array + { + return array_merge(static::package(), static::user()); + } +} diff --git a/src/phparkitect.php b/src/phparkitect.php index 6ae716e..a31084a 100644 --- a/src/phparkitect.php +++ b/src/phparkitect.php @@ -3,22 +3,10 @@ declare(strict_types=1); use Arkitect\CLI\Config; -use Illuminate\Support\Arr; -use Mortexa\LaravelArkitect\CreateApplication; +use Mortexa\LaravelArkitect\RuleLoader; return static function (Config $config): void { - $app = CreateApplication::app(); - - $package_config = $app->make('config')['arkitect']; - - $rules = []; - - $rules = array_merge($rules, Arr::flatten($package_config['rules'])); - - foreach (glob($app->basePath('tests/Architecture/*.php')) as $file) { - $class = basename($file, '.php'); - $rules[] = 'Tests\\Architecture\\'.$class; - } + $rules = RuleLoader::all(); foreach ($rules as $rule) { if ($rule::directoryExists()) { diff --git a/tests/Feature/RuleLoaderTest.php b/tests/Feature/RuleLoaderTest.php new file mode 100644 index 0000000..9227fe7 --- /dev/null +++ b/tests/Feature/RuleLoaderTest.php @@ -0,0 +1,26 @@ +