# Класс HttpSoft\Request\RequestFactory

Фабрика для создания HttpSoft\Request\Request, реализует Psr\Http\Message\RequestFactoryInterface.

Исходный код на GitHub.

use HttpSoft\Request\RequestFactory;

$factory = new RequestFactory();
$request = $factory->createRequest('GET', 'http://example.com');
$request->getMethod(); // 'GET'
$request->getProtocolVersion(); // '1.1'
$request->getBody()->getContents(); // ''
(string) $request->getUri(); // 'http://example.com'
$request->getHeaders(); // ['Host' => ['example.com']]

$request = RequestFactory::create(
    'POST',
    'http://example.com/path',
    'data://,Content',
    ['Content-Type' => 'text/html'],
    '1.0'
);
$request->getMethod(); // 'POST'
$request->getProtocolVersion(); // '1.0'
$request->getBody()->getContents(); // 'Content'
(string) $request->getUri(); // 'http://example.com/path'
$request->getHeaders(); // ['Host' => ['example.com'], 'Content-Type' => ['text/html']]

# Публичные методы

Оригинальное подробное описание методов смотрите в Psr\Http\Message\RequestFactoryInterface.

# create

Создает новый экземпляр HttpSoft\Request\Request (статический метод).

/**
 * @param string $method
 * @param UriInterface|string $uri
 * @param StreamInterface|string|resource $body
 * @param array $headers
 * @param string $protocol
 * @return RequestInterface
 */
public static function create(
    string $method,
    $uri,
    $body = 'php://temp',
    array $headers = [],
    string $protocol = '1.1'
): RequestInterface;

# createRequest

Создает новый экземпляр HttpSoft\Request\Request.

/**
 * @param string $method
 * @param UriInterface|string $uri
 * @return RequestInterface
 */
public function createRequest(string $method, $uri): RequestInterface;