Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
AuthenticatorServiceProvider
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 register
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 boot
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Helpers;
6
7use Engelsystem\Config\Config;
8use Engelsystem\Container\ServiceProvider;
9
10class AuthenticatorServiceProvider extends ServiceProvider
11{
12    public function register(): void
13    {
14        /** @var Authenticator $authenticator */
15        $authenticator = $this->app->make(Authenticator::class);
16
17        $this->app->instance(Authenticator::class, $authenticator);
18        $this->app->instance('authenticator', $authenticator);
19        $this->app->instance('auth', $authenticator);
20    }
21
22    public function boot(): void
23    {
24        /** @var Authenticator $authenticator */
25        $authenticator = $this->app->get(Authenticator::class);
26
27        /** @var Config $config */
28        $config = $this->app->get('config');
29        $authenticator->setPasswordAlgorithm($config->get('password_algorithm'));
30        $authenticator->setGuestRole($config->get('auth_guest_role', $authenticator->getGuestRole()));
31        $authenticator->setDefaultRole($config->get('auth_default_role', $authenticator->getDefaultRole()));
32    }
33}