antaresproject/core

View on GitHub
src/components/auth/src/Auth/Passwords/PasswordBrokerManager.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

/**
 * Part of the Antares package.
 *
 * NOTICE OF LICENSE
 *
 * Licensed under the 3-clause BSD License.
 *
 * This source file is subject to the 3-clause BSD License that is
 * bundled with this package in the LICENSE file.
 *
 * @package    Antares Core
 * @version    0.9.0
 * @author     Original Orchestral https://github.com/orchestral
 * @author     Antares Team
 * @license    BSD License (3-clause)
 * @copyright  (c) 2017, Antares
 * @link       http://antaresproject.io
 */


namespace Antares\Auth\Passwords;

use InvalidArgumentException;
use Illuminate\Auth\Passwords\PasswordBrokerManager as BaseManager;

class PasswordBrokerManager extends BaseManager
{

    /**
     * Resolve the given broker.
     *
     * @param  string  $name
     * @return \Illuminate\Contracts\Auth\PasswordBroker
     */
    protected function resolve($name)
    {
        $config = $this->getConfig($name);
        if (is_null($config)) {
            throw new InvalidArgumentException("Password resetter [{$name}] is not defined.");
        }
        // The password broker uses a token repository to validate tokens and send user
        // password e-mails, as well as validating that password reset process as an
        // aggregate service of sorts providing a convenient interface for resets.
        return new PasswordBroker(
                $this->createTokenRepository($config), $this->app->make('auth')->createUserProvider($config['provider']), $this->app->make('antares.notifier')->driver(), $config['email']
        );
    }

}