Rocket.php
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
declare(strict_types=1);
namespace Yansongda\Pay;
use ArrayAccess;
use JsonSerializable as JsonSerializableInterface;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\RequestInterface;
use Yansongda\Pay\Contract\DirectionInterface;
use Yansongda\Pay\Contract\PackerInterface;
use Yansongda\Supports\Collection;
use Yansongda\Supports\Traits\Accessable;
use Yansongda\Supports\Traits\Arrayable;
use Yansongda\Supports\Traits\Serializable;
class Rocket implements JsonSerializableInterface, ArrayAccess
{
use Accessable;
use Arrayable;
use Serializable;
private ?RequestInterface $radar = null;
private array $params = [];
private ?Collection $payload = null;
private string $packer = PackerInterface::class;
private string $direction = DirectionInterface::class;
/**
* @var null|array|Collection|MessageInterface
*/
private $destination;
private ?MessageInterface $destinationOrigin = null;
public function getRadar(): ?RequestInterface
{
return $this->radar;
}
public function setRadar(?RequestInterface $radar): Rocket
{
$this->radar = $radar;
return $this;
}
public function getParams(): array
{
return $this->params;
}
public function setParams(array $params): Rocket
{
$this->params = $params;
return $this;
}
public function mergeParams(array $params): Rocket
{
$this->params = array_merge($this->params, $params);
return $this;
}
public function getPayload(): ?Collection
{
return $this->payload;
}
public function setPayload(?Collection $payload): Rocket
{
$this->payload = $payload;
return $this;
}
public function mergePayload(array $payload): Rocket
{
if (empty($this->payload)) {
$this->payload = new Collection();
}
$this->payload = $this->payload->merge($payload);
return $this;
}
public function getPacker(): string
{
return $this->packer;
}
public function setPacker(string $packer): Rocket
{
$this->packer = $packer;
return $this;
}
public function getDirection(): string
{
return $this->direction;
}
public function setDirection(string $direction): Rocket
{
$this->direction = $direction;
return $this;
}
/**
* @return null|array|Collection|MessageInterface
*/
public function getDestination()
{
return $this->destination;
}
/**
* @param null|array|Collection|MessageInterface $destination
*/
public function setDestination($destination): Rocket
{
$this->destination = $destination;
return $this;
}
public function getDestinationOrigin(): ?MessageInterface
{
return $this->destinationOrigin;
}
public function setDestinationOrigin(?MessageInterface $destinationOrigin): Rocket
{
$this->destinationOrigin = $destinationOrigin;
return $this;
}
}