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

IlyasDeckers / ody-core / 13532154862

25 Feb 2025 10:24PM UTC coverage: 30.374% (+1.7%) from 28.706%
13532154862

push

github

web-flow
Update php.yml

544 of 1791 relevant lines covered (30.37%)

9.13 hits per line

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

18.18
/src/Factory/Psr17/SlimHttpServerRequestCreator.php
1
<?php
2
declare(strict_types=1);
3

4
namespace Ody\Core\Factory\Psr17;
5

6
use Ody\Core\Interfaces\ServerRequestCreatorInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
use RuntimeException;
9

10
use function class_exists;
11

12
class SlimHttpServerRequestCreator implements ServerRequestCreatorInterface
13
{
14
    protected ServerRequestCreatorInterface $serverRequestCreator;
15

16
    protected static string $serverRequestDecoratorClass = 'Ody\Core\Http\ServerRequest';
17

18
    public function __construct(ServerRequestCreatorInterface $serverRequestCreator)
×
19
    {
20
        $this->serverRequestCreator = $serverRequestCreator;
×
21
    }
22

23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function createServerRequestFromGlobals(): ServerRequestInterface
×
27
    {
28
        if (!static::isServerRequestDecoratorAvailable()) {
×
29
            throw new RuntimeException('The Slim-Http ServerRequest decorator is not available.');
×
30
        }
31

32
        $request = $this->serverRequestCreator->createServerRequestFromGlobals();
×
33

34
        if (
35
            !((
36
                $decoratedServerRequest = new static::$serverRequestDecoratorClass($request)
×
37
                ) instanceof ServerRequestInterface)
38
        ) {
39
            throw new RuntimeException(get_called_class() . ' could not instantiate a decorated server request.');
×
40
        }
41

42
        return $decoratedServerRequest;
×
43
    }
44

45
    public static function isServerRequestDecoratorAvailable(): bool
1✔
46
    {
47
        return class_exists(static::$serverRequestDecoratorClass);
1✔
48
    }
49
}
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