DeleteStreamRequestFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildRequest() 0 10 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