<html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><?php

namespace Intervention\HttpAuth;

use Exception;

class Environment
{
    /**
     * Available auth tokens
     *
     * @var array
     */
    protected $tokenClassnames = [
        Token\PhpAuthUser::class,
        Token\HttpAuthentification::class,
        Token\RedirectHttpAuthorization::class,
        Token\PhpAuthDigest::class,
        Token\HttpAuthorization::class,
    ];

    /**
     * Get first active auth token from all available tokens
     *
     * @return TokenInterface
     */
    public function getToken(): TokenInterface
    {
        foreach ($this->tokenClassnames as $classname) {
            if ($auth = $this->getActiveTokenOrNull($classname)) {
                return $auth;
            }
        }

        return new Token\NullToken();
    }

    /**
     * Try to parse auth tok