Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 2 | Features | 1 |
1 | <?php |
||
38 | public function boot() |
||
39 | { |
||
40 | $this->publishes([ |
||
41 | __DIR__.'/lang/validation/'.App::getLocale().'.php' => resource_path('lang/validation/'.App::getLocale().'.php'), |
||
|
|||
42 | ]); |
||
43 | |||
44 | foreach (glob(__DIR__.'/Rules/*.php') as $file) { |
||
45 | require_once $file; |
||
46 | |||
47 | // get the file name of the current file without the extension |
||
48 | // which is essentially the class name |
||
49 | $class = basename($file, '.php'); |
||
50 | |||
51 | $Rule = 'Iamfarhad\Validation\Rules'; |
||
52 | if (class_exists($Rule.'\\'.$class)) { |
||
53 | $reflectionClass = new \ReflectionClass($Rule.'\\'.$class); |
||
54 | if (! $reflectionClass->isSubclassOf(AbstractValidationRule::class)) { |
||
55 | throw new \Exception('this extension ('.$class.') is not instance of AbstractValidationRule'); |
||
56 | } |
||
57 | // Register extension |
||
58 | $module = $reflectionClass->newInstanceArgs([]); |
||
59 | $module->register(); |
||
60 | } |
||
64 |