Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Nyholm | |
100.00% |
15 / 15 |
|
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| serverRequest | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Core\Factory; |
| 6 | |
| 7 | use Celemas\Core\Exception\RuntimeException; |
| 8 | use Nyholm\Psr7\Factory\Psr17Factory; |
| 9 | use Nyholm\Psr7Server\ServerRequestCreator; |
| 10 | use Override; |
| 11 | use Psr\Http\Message\ServerRequestInterface; |
| 12 | use Throwable; |
| 13 | |
| 14 | /** @api */ |
| 15 | class Nyholm extends AbstractFactory |
| 16 | { |
| 17 | protected Psr17Factory $factory; |
| 18 | |
| 19 | public function __construct() |
| 20 | { |
| 21 | try { |
| 22 | $factory = new Psr17Factory(); |
| 23 | $this->factory = $factory; |
| 24 | $this->responseFactory = $factory; |
| 25 | $this->streamFactory = $factory; |
| 26 | $this->requestFactory = $factory; |
| 27 | $this->serverRequestFactory = $factory; |
| 28 | $this->uploadedFileFactory = $factory; |
| 29 | $this->uriFactory = $factory; |
| 30 | |
| 31 | // @codeCoverageIgnoreStart |
| 32 | } catch (Throwable) { |
| 33 | throw new RuntimeException('Install laminas/laminas-diactoros'); |
| 34 | |
| 35 | // @codeCoverageIgnoreEnd |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | #[Override] |
| 40 | public function serverRequest(): ServerRequestInterface |
| 41 | { |
| 42 | $creator = new ServerRequestCreator( |
| 43 | $this->factory, // ServerRequestFactory |
| 44 | $this->factory, // UriFactory |
| 45 | $this->factory, // UploadedFileFactory |
| 46 | $this->factory, // StreamFactory |
| 47 | ); |
| 48 | |
| 49 | return $creator->fromGlobals(); |
| 50 | } |
| 51 | } |
Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not
necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once.
Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 21 | try { |
| 22 | $factory = new Psr17Factory(); |
| 23 | $this->factory = $factory; |
| 24 | $this->responseFactory = $factory; |
| 25 | $this->streamFactory = $factory; |
| 26 | $this->requestFactory = $factory; |
| 27 | $this->serverRequestFactory = $factory; |
| 28 | $this->uploadedFileFactory = $factory; |
| 29 | $this->uriFactory = $factory; |
| 37 | } |
| 42 | $creator = new ServerRequestCreator( |
| 43 | $this->factory, // ServerRequestFactory |
| 44 | $this->factory, // UriFactory |
| 45 | $this->factory, // UploadedFileFactory |
| 46 | $this->factory, // StreamFactory |
| 47 | ); |
| 48 | |
| 49 | return $creator->fromGlobals(); |
| 50 | } |