Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
9 / 9 |
| RulesServiceProvider | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
9 / 9 |
| boot | |
100.00% |
1 / 1 |
1 | |
100.00% |
5 / 5 |
|||
| register | |
100.00% |
1 / 1 |
3 | |
100.00% |
4 / 4 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\ValidationRules\Providers; |
| 4 | |
| 5 | use Illuminate\Support\Collection; |
| 6 | use Illuminate\Support\ServiceProvider; |
| 7 | use Qmp\Laravel\DictionaryFormatter\Facades\DictionaryFormatter; |
| 8 | use Qmp\Laravel\Tests\ValidationRules\Mock\DictionaryFormatterMock; |
| 9 | class RulesServiceProvider extends ServiceProvider |
| 10 | { |
| 11 | /** |
| 12 | * Boot all the validation rules. |
| 13 | * |
| 14 | * @return void |
| 15 | */ |
| 16 | public function boot() |
| 17 | { |
| 18 | Collection::make(glob(__DIR__ . '/../Rules/*.php'))->each(function ($rule) { |
| 19 | $class = 'Qmp\\Laravel\\ValidationRules\\Rules\\' . pathinfo($rule, PATHINFO_FILENAME); |
| 20 | $class::boot(); |
| 21 | }); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Undocumented function |
| 26 | * |
| 27 | * @return void |
| 28 | */ |
| 29 | public function register() |
| 30 | { |
| 31 | if (config('app.env') === 'testing' && env('DEPENDENCY_NAME') === 'validation-rules') { |
| 32 | $loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
| 33 | $loader->alias(DictionaryFormatter::class, DictionaryFormatterMock::class); |
| 34 | } |
| 35 | } |
| 36 | } |