1 | <?php |
||
20 | abstract class Handler |
||
21 | { |
||
22 | const SUCCESS = 'SUCCESS'; |
||
23 | const FAIL = 'FAIL'; |
||
24 | |||
25 | /** |
||
26 | * @var \EasyWeChat\Payment\Application |
||
27 | */ |
||
28 | protected $app; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $message; |
||
34 | |||
35 | /** |
||
36 | * @var string|null |
||
37 | */ |
||
38 | protected $fail; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $attributes = []; |
||
44 | |||
45 | /** |
||
46 | * Check sign. |
||
47 | * If failed, throws an exception. |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | protected $check = true; |
||
52 | |||
53 | /** |
||
54 | * Respond with sign. |
||
55 | * |
||
56 | * @var bool |
||
57 | */ |
||
58 | protected $sign = false; |
||
59 | |||
60 | /** |
||
61 | * @param \EasyWeChat\Payment\Application $app |
||
62 | */ |
||
63 | public function __construct($app) |
||
67 | |||
68 | /** |
||
69 | * Handle incoming notify. |
||
70 | * |
||
71 | * @param callable $callback |
||
72 | * |
||
73 | * @return \Symfony\Component\HttpFoundation\Response |
||
74 | */ |
||
75 | abstract public function handle(callable $callback): Response; |
||
76 | |||
77 | /** |
||
78 | * @param string $message |
||
79 | */ |
||
80 | public function fail(string $message) |
||
84 | |||
85 | /** |
||
86 | * @param array $attributes |
||
87 | * @param bool $sign |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function respondWith(array $attributes, bool $sign = false) |
||
98 | |||
99 | /** |
||
100 | * Build xml and return the response to WeChat. |
||
101 | * |
||
102 | * @return \Symfony\Component\HttpFoundation\Response |
||
103 | */ |
||
104 | public function toResponse(): Response |
||
119 | |||
120 | /** |
||
121 | * Return the notify message from request. |
||
122 | * |
||
123 | * @return array |
||
124 | * |
||
125 | * @throws \EasyWeChat\Kernel\Exceptions\Exception |
||
126 | */ |
||
127 | public function getMessage(): array |
||
149 | |||
150 | /** |
||
151 | * Decrypt message. |
||
152 | * |
||
153 | * @param string $key |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | public function decryptMessage(string $key): string |
||
168 | |||
169 | /** |
||
170 | * Validate the request params. |
||
171 | * |
||
172 | * @param array $message |
||
173 | * |
||
174 | * @throws \EasyWeChat\Payment\Kernel\Exceptions\InvalidSignException |
||
175 | */ |
||
176 | protected function validate(array $message) |
||
185 | |||
186 | /** |
||
187 | * @param mixed $result |
||
188 | */ |
||
189 | protected function strict($result) |
||
195 | } |
||
196 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.