DeleteStreamRequestFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace RayRutjes\GetEventStore\Client\Http;
4
5
use GuzzleHttp\Psr7\Request;
6
use Psr\Http\Message\RequestInterface;
7
use RayRutjes\GetEventStore\StreamId;
8
9
final class DeleteStreamRequestFactory implements RequestFactoryInterface
10
{
11
    /**
12
     * @var StreamId
13
     */
14
    private $streamId;
15
16
    /**
17
     * @param StreamId $streamId
18
     */
19
    public function __construct(StreamId $streamId)
20
    {
21
        $this->streamId = $streamId;
22
    }
23
24
    /**
25
     * @return RequestInterface
26
     */
27
    public function buildRequest(): RequestInterface
28
    {
29
        return new Request(
30
            'DELETE',
31
            sprintf('streams/%s', $this->streamId->toString()),
32
            [
33
                RequestHeader::HARD_DELETE => 'true',
34
            ]
35
        );
36
    }
37
}
38