Completed
Pull Request — master (#1)
by Raymond
03:07
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %
Metric Value
dl 5
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 View Code Duplication
final class DeletePersistentSubscriptionRequestFactory implements RequestFactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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