Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ValidationServiceProvider | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| register | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Engelsystem\Http\Validation; |
| 6 | |
| 7 | use Engelsystem\Application; |
| 8 | use Engelsystem\Container\ServiceProvider; |
| 9 | use Engelsystem\Controllers\BaseController; |
| 10 | |
| 11 | class ValidationServiceProvider extends ServiceProvider |
| 12 | { |
| 13 | public function register(): void |
| 14 | { |
| 15 | $validator = $this->app->make(Validator::class); |
| 16 | $this->app->instance(Validator::class, $validator); |
| 17 | $this->app->instance('validator', $validator); |
| 18 | |
| 19 | $this->app->afterResolving(function ($object, Application $app): void { |
| 20 | if (!$object instanceof BaseController) { |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | $object->setValidator($app->get(Validator::class)); |
| 25 | }); |
| 26 | } |
| 27 | } |