• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

valkyrjaio / valkyrja / 13049807881

30 Jan 2025 09:53AM UTC coverage: 47.589% (-0.03%) from 47.621%
13049807881

push

github

MelechMizrachi
PHP CS Fixer: Style fixes.

18 of 18 new or added lines in 5 files covered. (100.0%)

301 existing lines in 19 files now uncovered.

5201 of 10929 relevant lines covered (47.59%)

18.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/Valkyrja/Http/Message/Factory/ServerFactory.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <melechmizrachi@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Valkyrja\Http\Message\Factory;
15

16
use function function_exists;
17

18
/**
19
 * Abstract Class ServerFactory.
20
 *
21
 * @author Melech Mizrachi
22
 */
23
abstract class ServerFactory
24
{
25
    /**
26
     * Marshal the $_SERVER array.
27
     * Pre-processes and returns the $_SERVER superglobal.
28
     *
29
     * @param array<string, string> $server
30
     *
31
     * @return array<string, string>
32
     */
33
    public static function normalizeServer(array $server): array
34
    {
35
        $apacheRequestHeaders = self::apacheRequestHeaders();
180✔
36

37
        if (isset($server['HTTP_AUTHORIZATION']) || $apacheRequestHeaders === null) {
180✔
38
            return $server;
2✔
39
        }
40

41
        if (isset($apacheRequestHeaders['Authorization'])) {
178✔
42
            $server['HTTP_AUTHORIZATION'] = $apacheRequestHeaders['Authorization'];
174✔
43

44
            return $server;
174✔
45
        }
46

47
        if (isset($apacheRequestHeaders['authorization'])) {
4✔
48
            $server['HTTP_AUTHORIZATION'] = $apacheRequestHeaders['authorization'];
2✔
49

50
            return $server;
2✔
51
        }
52

53
        return $server;
2✔
54
    }
55

56
    /**
57
     * @return array{Authorization?: string, authorization?: string}|null
58
     */
59
    private static function apacheRequestHeaders(): array|null
60
    {
61
        if (function_exists('apache_request_headers')) {
180✔
62
            // This seems to be the only way to get the Authorization header on Apache
63
            return apache_request_headers();
180✔
64
        }
65

UNCOV
66
        return null;
×
67
    }
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc