Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
UsesAuthServiceProvider
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 register
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Controllers\Api;
6
7use Engelsystem\Application;
8use Engelsystem\Container\ServiceProvider;
9use Engelsystem\Helpers\Authenticator;
10
11class 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}