Passed
Pull Request — master (#754)
by Songda
01:52
created

Rocket::setPacker()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay;
6
7
use ArrayAccess;
8
use JsonSerializable as JsonSerializableInterface;
9
use Psr\Http\Message\MessageInterface;
10
use Psr\Http\Message\RequestInterface;
11
use Yansongda\Pay\Contract\PackerInterface;
12
use Yansongda\Pay\Contract\ParserInterface;
13
use Yansongda\Supports\Collection;
14
use Yansongda\Supports\Traits\Accessable;
15
use Yansongda\Supports\Traits\Arrayable;
16
use Yansongda\Supports\Traits\Serializable;
17
18
class Rocket implements JsonSerializableInterface, ArrayAccess
19
{
20
    use Accessable;
21
    use Arrayable;
22
    use Serializable;
23
24
    private ?RequestInterface $radar = null;
25
26
    private array $params = [];
27
28
    private ?Collection $payload = null;
29
30
    private string $packer = PackerInterface::class;
31
32
    private string $direction = ParserInterface::class;
33
34
    /**
35
     * @var \Yansongda\Supports\Collection|\Psr\Http\Message\MessageInterface|array|null
36
     */
37
    private $destination = null;
38
39
    private ?MessageInterface $destinationOrigin = null;
40
41
    public function getRadar(): ?RequestInterface
42
    {
43
        return $this->radar;
44
    }
45
46
    public function setRadar(?RequestInterface $radar): Rocket
47
    {
48
        $this->radar = $radar;
49
50
        return $this;
51
    }
52
53
    public function getParams(): array
54
    {
55
        return $this->params;
56
    }
57
58
    public function setParams(array $params): Rocket
59
    {
60
        $this->params = $params;
61
62
        return $this;
63
    }
64
65
    public function mergeParams(array $params): Rocket
66
    {
67
        $this->params = array_merge($this->params, $params);
68
69
        return $this;
70
    }
71
72
    public function getPayload(): ?Collection
73
    {
74
        return $this->payload;
75
    }
76
77
    public function setPayload(?Collection $payload): Rocket
78
    {
79
        $this->payload = $payload;
80
81
        return $this;
82
    }
83
84
    public function mergePayload(array $payload): Rocket
85
    {
86
        if (empty($this->payload)) {
87
            $this->payload = new Collection();
88
        }
89
90
        $this->payload = $this->payload->merge($payload);
0 ignored issues
show
Bug introduced by
The method merge() does not exist on null. ( Ignorable by Annotation )

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

90
        /** @scrutinizer ignore-call */ 
91
        $this->payload = $this->payload->merge($payload);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
91
92
        return $this;
93
    }
94
95
    public function getPacker(): string
96
    {
97
        return $this->packer;
98
    }
99
100
    public function setPacker(string $packer): Rocket
101
    {
102
        $this->packer = $packer;
103
104
        return $this;
105
    }
106
107
    public function getDirection(): string
108
    {
109
        return $this->direction;
110
    }
111
112
    public function setDirection(string $direction): Rocket
113
    {
114
        $this->direction = $direction;
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return \Psr\Http\Message\MessageInterface|\Yansongda\Supports\Collection|array|null
121
     */
122
    public function getDestination()
123
    {
124
        return $this->destination;
125
    }
126
127
    /**
128
     * @param \Psr\Http\Message\MessageInterface|\Yansongda\Supports\Collection|array|null $destination
129
     */
130
    public function setDestination($destination): Rocket
131
    {
132
        $this->destination = $destination;
133
134
        return $this;
135
    }
136
137
    public function getDestinationOrigin(): ?MessageInterface
138
    {
139
        return $this->destinationOrigin;
140
    }
141
142
    public function setDestinationOrigin(?MessageInterface $destinationOrigin): Rocket
143
    {
144
        $this->destinationOrigin = $destinationOrigin;
145
146
        return $this;
147
    }
148
}
149