Completed
Push — master ( b4ceaf...dfafd4 )
by Stéphane
01:15
created

ApiResponseFactory::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace StephaneCoinon\SendGridActivity\Support\Testing;
4
5
use Http\Message\MessageFactory\GuzzleMessageFactory;
6
7
class ApiResponseFactory
8
{
9
    protected $headers = [];
10
11
    public function __construct()
12
    {
13
        $this->json();
14
    }
15
16
    public function json(): self
17
    {
18
        $this->headers['Content-Type'] = 'application/json';
19
20
        return $this;
21
    }
22
23
    public function build($payload)
24
    {
25
        return (new GuzzleMessageFactory)->createResponse(
26
            200, '', $this->headers, json_encode($payload)
27
        );
28
    }
29
}
30