Completed
Pull Request — master (#1)
by Raymond
02:16
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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 DeletePersistentSubscriptionRequestFactory implements RequestFactoryInterface
10
{
11
    /**
12
     * @var StreamId
13
     */
14
    private $streamId;
15
16
    /**
17
     * @var string
18
     */
19
    private $groupName;
20
21
    /**
22
     * @param StreamId $streamId
23
     * @param string   $groupName
24
     */
25
    public function __construct(StreamId $streamId, string $groupName)
26
    {
27
        $this->streamId = $streamId;
28
        $this->groupName = $groupName;
29
    }
30
31
    /**
32
     * @return RequestInterface
33
     */
34
    public function buildRequest(): RequestInterface
35
    {
36
        return new Request(
37
            'DELETE',
38
            sprintf('subscriptions/%s/%s', $this->streamId->toString(), $this->groupName),
39
            [
40
                RequestHeader::CONTENT_TYPE => ContentType::JSON,
41
            ]
42
        );
43
    }
44
}
45