PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.3
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.3
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / intervention / httpauth / src / Environment.php

Environment.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.3, at vendor/intervention/httpauth/src/Environment.php

56 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Intervention\HttpAuth;
4
5 use Exception;
6
7 class Environment
8 {
9 /**
10 * Available auth tokens
11 *
12 * @var array
13 */
14 protected $tokenClassnames = [
15 Token\PhpAuthUser::class,
16 Token\HttpAuthentification::class,
17 Token\RedirectHttpAuthorization::class,
18 Token\PhpAuthDigest::class,
19 Token\HttpAuthorization::class,
20 ];
21
22 /**
23 * Get first active auth token from all available tokens
24 *
25 * @return TokenInterface
26 */
27 public function getToken(): TokenInterface
28 {
29 foreach ($this->tokenClassnames as $classname) {
30 if ($auth = $this->getActiveTokenOrNull($classname)) {
31 return $auth;
32 }
33 }
34
35 return new Token\NullToken();
36 }
37
38 /**
39 * Try to parse auth token from given classname. Returns token object
40 * if token is active and could be parsed or null.
41 *
42 * @param string $classname
43 * @return TokenInterface|null
44 */
45 private function getActiveTokenOrNull($classname)
46 {
47 try {
48 $auth = new $classname();
49 } catch (Exception $e) {
50 $auth = null;
51 }
52
53 return $auth;
54 }
55 }
56