Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
UsesAuthServiceProvider | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
register | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Engelsystem\Controllers\Api; |
6 | |
7 | use Engelsystem\Application; |
8 | use Engelsystem\Container\ServiceProvider; |
9 | use Engelsystem\Helpers\Authenticator; |
10 | |
11 | class UsesAuthServiceProvider extends ServiceProvider |
12 | { |
13 | public function register(): void |
14 | { |
15 | $this->app->afterResolving(function ($object, Application $app): void { |
16 | if (!$object instanceof ApiController || !method_exists($object, 'setAuth')) { |
17 | return; |
18 | } |
19 | |
20 | /** @var UsesAuth $object */ |
21 | $object->setAuth($app->get(Authenticator::class)); |
22 | }); |
23 | } |
24 | } |