0 follower

Final Class Yiisoft\DataResponse\DataResponseFactory

InheritanceYiisoft\DataResponse\DataResponseFactory
ImplementsYiisoft\DataResponse\DataResponseFactoryInterface

DataResponseFactory creates an instance of the data response {@see DataResponse}.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Psr\Http\Message\ResponseFactoryInterface $responseFactory, \Psr\Http\Message\StreamFactoryInterface $streamFactory )
$responseFactory \Psr\Http\Message\ResponseFactoryInterface
$streamFactory \Psr\Http\Message\StreamFactoryInterface

                public function __construct(
    private ResponseFactoryInterface $responseFactory,
    private StreamFactoryInterface $streamFactory,
) {
}

            
createResponse() public method

public Yiisoft\DataResponse\DataResponse createResponse ( mixed $data null, integer $code Status::OK, string $reasonPhrase '' )
$data mixed
$code integer
$reasonPhrase string

                public function createResponse($data = null, int $code = Status::OK, string $reasonPhrase = ''): DataResponse
{
    return new DataResponse($data, $code, $reasonPhrase, $this->responseFactory, $this->streamFactory);
}