Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RequestFactory
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 createRequest
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <dev@noladev.com>
8 * @copyright  Copyright (c) 2009-2027 NOLA Interactive, LLC.
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Http\Factory;
16
17use Psr\Http\Message\RequestFactoryInterface;
18use Psr\Http\Message\RequestInterface;
19use Psr\Http\Message\UriInterface;
20use Pop\Http\Client\Request;
21
22/**
23 * PSR-17 request factory class
24 *
25 * @category   Pop
26 * @package    Pop\Http
27 * @author     Nick Sagona, III <dev@noladev.com>
28 * @copyright  Copyright (c) 2009-2027 NOLA Interactive, LLC.
29 * @license    https://www.popphp.org/license     New BSD License
30 * @version    6.0.0
31 */
32class RequestFactory implements RequestFactoryInterface
33{
34
35    /**
36     * Create a new request
37     *
38     * @param  string             $method
39     * @param  UriInterface|string $uri
40     * @return RequestInterface
41     */
42    public function createRequest(string $method, $uri): RequestInterface
43    {
44        $uriString = ($uri instanceof UriInterface) ? (string)$uri : $uri;
45        return new Request($uriString, $method);
46    }
47
48}