Passed
Pull Request — master (#753)
by Songda
01:50
created

Rocket::setPacker()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
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\Supports\Collection;
13
use Yansongda\Supports\Traits\Accessable;
14
use Yansongda\Supports\Traits\Arrayable;
15
use Yansongda\Supports\Traits\Serializable;
16
17
class Rocket implements JsonSerializableInterface, ArrayAccess
18
{
19
    use Accessable;
20
    use Arrayable;
21
    use Serializable;
22
23
    private ?RequestInterface $radar = null;
24
25
    private array $params = [];
26
27
    private ?Collection $payload = null;
28
29
    private string $packer = PackerInterface::class;
30
31
    private ?string $direction = null;
32
33
    /**
34
     * @var \Yansongda\Supports\Collection|\Psr\Http\Message\MessageInterface|array|null
35
     */
36
    private $destination = null;
37
38
    private ?MessageInterface $destinationOrigin = null;
39
40
    public function getRadar(): ?RequestInterface
41
    {
42
        return $this->radar;
43
    }
44
45
    public function setRadar(?RequestInterface $radar): Rocket
46
    {
47
        $this->radar = $radar;
48
49
        return $this;
50
    }
51
52
    public function getParams(): array
53
    {
54
        return $this->params;
55
    }
56
57
    public function setParams(array $params): Rocket
58
    {
59
        $this->params = $params;
60
61
        return $this;
62
    }
63
64
    public function mergeParams(array $params): Rocket
65
    {
66
        $this->params = array_merge($this->params, $params);
67
68
        return $this;
69
    }
70
71
    public function getPayload(): ?Collection
72
    {
73
        return $this->payload;
74
    }
75
76
    public function setPayload(?Collection $payload): Rocket
77
    {
78
        $this->payload = $payload;
79
80
        return $this;
81
    }
82
83
    public function mergePayload(array $payload): Rocket
84
    {
85
        if (empty($this->payload)) {
86
            $this->payload = new Collection();
87
        }
88
89
        $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

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