-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUtil.php
More file actions
55 lines (47 loc) · 1.1 KB
/
Util.php
File metadata and controls
55 lines (47 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace PhpMiddleware\HttpAuthentication;
final class Util
{
/**
* @codeCoverageIgnore
*/
private function __construct()
{
}
/**
* @param array $params
*
* @return string md5
*/
public static function md5Implode(array $params)
{
return md5(implode(':', $params));
}
/**
* @param string $scheme
* @param array $challenges
*
* @return string
*/
public static function buildHeader($scheme, array $challenges)
{
$challenge = self::buildChallengeString($challenges);
if (empty($challenge)) {
return $scheme;
}
return sprintf('%s %s', $scheme, $challenge);
}
/**
* @param array $serviceChallenge
*
* @return string
*/
private static function buildChallengeString(array $serviceChallenge)
{
$challengePairs = [];
foreach ($serviceChallenge as $challenge => $value) {
$challengePairs[] = sprintf('%s="%s"', $challenge, addslashes($value));
}
return implode(', ', $challengePairs);
}
}