Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
20 / 20
83.33% covered (warning)
83.33%
10 / 12
23.08% covered (danger)
23.08%
3 / 13
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Nyholm
100.00% covered (success)
100.00%
20 / 20
83.33% covered (warning)
83.33%
10 / 12
23.08% covered (danger)
23.08%
3 / 13
100.00% covered (success)
100.00%
2 / 2
11.28
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
13 / 13
81.82% covered (warning)
81.82%
9 / 11
16.67% covered (danger)
16.67%
2 / 12
100.00% covered (success)
100.00%
1 / 1
8.21
 serverRequest
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Celema\Core\Factory;
6
7use Celema\Core\Exception\RuntimeException;
8use Nyholm\Psr7\Factory\Psr17Factory;
9use Nyholm\Psr7Server\ServerRequestCreator;
10use Override;
11use Psr\Http\Message\ServerRequestInterface;
12
13/** @api */
14class Nyholm extends AbstractFactory
15{
16    protected Psr17Factory $factory;
17
18    public function __construct()
19    {
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
21            throw new RuntimeException(
22                'Install nyholm/psr7 and nyholm/psr7-server to use the default '
23                    . 'PSR-7 factory, or pass a custom Factory implementation to the App constructor',
24            );
25        }
26
27        $factory = new Psr17Factory();
28        $this->factory = $factory;
29        $this->responseFactory = $factory;
30        $this->streamFactory = $factory;
31        $this->requestFactory = $factory;
32        $this->serverRequestFactory = $factory;
33        $this->uploadedFileFactory = $factory;
34        $this->uriFactory = $factory;
35    }
36
37    #[Override]
38    public function serverRequest(): ServerRequestInterface
39    {
40        $creator = new ServerRequestCreator(
41            $this->factory, // ServerRequestFactory
42            $this->factory, // UriFactory
43            $this->factory, // UploadedFileFactory
44            $this->factory, // StreamFactory
45        );
46
47        return $creator->fromGlobals();
48    }
49}

Paths

Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once. Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

Nyholm->__construct
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
21            throw new RuntimeException(
22                'Install nyholm/psr7 and nyholm/psr7-server to use the default '
23                    . 'PSR-7 factory, or pass a custom Factory implementation to the App constructor',
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
27        $factory = new Psr17Factory();
28        $this->factory = $factory;
29        $this->responseFactory = $factory;
30        $this->streamFactory = $factory;
31        $this->requestFactory = $factory;
32        $this->serverRequestFactory = $factory;
33        $this->uploadedFileFactory = $factory;
34        $this->uriFactory = $factory;
35    }
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
21            throw new RuntimeException(
22                'Install nyholm/psr7 and nyholm/psr7-server to use the default '
23                    . 'PSR-7 factory, or pass a custom Factory implementation to the App constructor',
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
27        $factory = new Psr17Factory();
28        $this->factory = $factory;
29        $this->responseFactory = $factory;
30        $this->streamFactory = $factory;
31        $this->requestFactory = $factory;
32        $this->serverRequestFactory = $factory;
33        $this->uploadedFileFactory = $factory;
34        $this->uriFactory = $factory;
35    }
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
21            throw new RuntimeException(
22                'Install nyholm/psr7 and nyholm/psr7-server to use the default '
23                    . 'PSR-7 factory, or pass a custom Factory implementation to the App constructor',
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
27        $factory = new Psr17Factory();
28        $this->factory = $factory;
29        $this->responseFactory = $factory;
30        $this->streamFactory = $factory;
31        $this->requestFactory = $factory;
32        $this->serverRequestFactory = $factory;
33        $this->uploadedFileFactory = $factory;
34        $this->uriFactory = $factory;
35    }
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
21            throw new RuntimeException(
22                'Install nyholm/psr7 and nyholm/psr7-server to use the default '
23                    . 'PSR-7 factory, or pass a custom Factory implementation to the App constructor',
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
27        $factory = new Psr17Factory();
28        $this->factory = $factory;
29        $this->responseFactory = $factory;
30        $this->streamFactory = $factory;
31        $this->requestFactory = $factory;
32        $this->serverRequestFactory = $factory;
33        $this->uploadedFileFactory = $factory;
34        $this->uriFactory = $factory;
35    }
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
21            throw new RuntimeException(
22                'Install nyholm/psr7 and nyholm/psr7-server to use the default '
23                    . 'PSR-7 factory, or pass a custom Factory implementation to the App constructor',
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
27        $factory = new Psr17Factory();
28        $this->factory = $factory;
29        $this->responseFactory = $factory;
30        $this->streamFactory = $factory;
31        $this->requestFactory = $factory;
32        $this->serverRequestFactory = $factory;
33        $this->uploadedFileFactory = $factory;
34        $this->uriFactory = $factory;
35    }
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
21            throw new RuntimeException(
22                'Install nyholm/psr7 and nyholm/psr7-server to use the default '
23                    . 'PSR-7 factory, or pass a custom Factory implementation to the App constructor',
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
20        if (!class_exists(Psr17Factory::class) || !class_exists(ServerRequestCreator::class)) {
 
27        $factory = new Psr17Factory();
28        $this->factory = $factory;
29        $this->responseFactory = $factory;
30        $this->streamFactory = $factory;
31        $this->requestFactory = $factory;
32        $this->serverRequestFactory = $factory;
33        $this->uploadedFileFactory = $factory;
34        $this->uriFactory = $factory;
35    }
Nyholm->serverRequest
40        $creator = new ServerRequestCreator(
41            $this->factory, // ServerRequestFactory
42            $this->factory, // UriFactory
43            $this->factory, // UploadedFileFactory
44            $this->factory, // StreamFactory
45        );
46
47        return $creator->fromGlobals();
48    }