Passed
Pull Request — master (#75)
by
unknown
24:56 queued 09:54
created

DataResponseProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
namespace App\Stream\Value;
4
5
class DataResponseProvider
6
{
7
    /** @var mixed */
8
    private $data;
9
    private ?int $code = null;
10
    private array $headers = [];
11
    private ?string $format = null;
12
    private array $params = [];
13
14
    public function __construct($data, string $format = null, array $params = [])
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

14
    public function __construct($data, string $format = null, /** @scrutinizer ignore-unused */ array $params = [])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
15
    {
16
        $this->data = $data;
17
        $this->format = $format;
18
    }
19
    public function getCode(): ?int
20
    {
21
        return $this->code;
22
    }
23
    public function getHeaders(): array
24
    {
25
        return $this->headers;
26
    }
27
    public function getFormat(): ?string
28
    {
29
        return $this->format;
30
    }
31
    public function getParams(): array
32
    {
33
        return $this->params;
34
    }
35
    public function getData()
36
    {
37
        return $this->data;
38
    }
39
40
    public function setCode(?int $code = 200): self
41
    {
42
        $this->code = $code;
43
        return $this;
44
    }
45
    public function setHeaders(array $headers = []): self
46
    {
47
        $this->headers = $headers;
48
        return $this;
49
    }
50
    public function addHeaders(array $headers = []): self
51
    {
52
        $this->headers = [...$this->headers, ...$headers];
53
        return $this;
54
    }
55
    public function setFormat(?string $format, array $params = null): self
56
    {
57
        $this->format = $format;
58
        if ($params !== null) {
59
            $this->params = $params;
60
        }
61
        return $this;
62
    }
63
}
64