Complex classes like HttpRedirectBinding often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use HttpRedirectBinding, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
26 | class HttpRedirectBinding extends AbstractBinding |
||
27 | { |
||
28 | /** |
||
29 | * @param MessageContext $context |
||
30 | * @param null|string $destination |
||
31 | * |
||
32 | * @return \Symfony\Component\HttpFoundation\Response |
||
33 | */ |
||
34 | 2 | public function send(MessageContext $context, $destination = null) |
|
42 | |||
43 | /** |
||
44 | * @param Request $request |
||
45 | * @param MessageContext $context |
||
46 | */ |
||
47 | 2 | public function receive(Request $request, MessageContext $context) |
|
53 | |||
54 | /** |
||
55 | * @param array $data |
||
56 | * @param MessageContext $context |
||
57 | * |
||
58 | * @throws \Exception |
||
59 | */ |
||
60 | 2 | protected function processData(array $data, MessageContext $context) |
|
76 | |||
77 | /** |
||
78 | * @param array $data |
||
79 | * |
||
80 | * @return string |
||
81 | * |
||
82 | * @throws LightSamlBindingException |
||
83 | */ |
||
84 | 2 | protected function getMessageStringFromData(array $data) |
|
94 | |||
95 | /** |
||
96 | * @param array $data |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | 1 | protected function getEncodingFromData(array $data) |
|
108 | |||
109 | /** |
||
110 | * @param string $msg |
||
111 | * @param string $encoding |
||
112 | * |
||
113 | * @throws \LightSaml\Error\LightSamlBindingException |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | 1 | protected function decodeMessageString($msg, $encoding) |
|
128 | |||
129 | 1 | protected function loadRelayState(SamlMessage $message, array $data) |
|
135 | |||
136 | 1 | protected function loadSignature(SamlMessage $message, array $data) |
|
147 | |||
148 | /** |
||
149 | * @param MessageContext $context |
||
150 | * @param string|null $destination |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | 2 | protected function getRedirectURL(MessageContext $context, $destination) |
|
169 | |||
170 | /** |
||
171 | * @param SamlMessage $message |
||
172 | * @param MessageContext $context |
||
173 | * |
||
174 | * @return string |
||
175 | */ |
||
176 | 2 | protected function getMessageEncodedXml(SamlMessage $message, MessageContext $context) |
|
191 | |||
192 | /** |
||
193 | * @param SamlMessage $message |
||
194 | * @param string $xml |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | 2 | protected function addMessageToUrl(SamlMessage $message, $xml) |
|
209 | |||
210 | /** |
||
211 | * @param string $msg |
||
212 | * @param SamlMessage $message |
||
213 | */ |
||
214 | 2 | protected function addRelayStateToUrl(&$msg, SamlMessage $message) |
|
220 | |||
221 | /** |
||
222 | * @param string $msg |
||
223 | * @param SignatureWriter|null $signature |
||
224 | */ |
||
225 | 2 | protected function addSignatureToUrl(&$msg, SignatureWriter $signature = null) |
|
236 | |||
237 | /** |
||
238 | * @param string $msg |
||
239 | * @param SamlMessage $message |
||
240 | * @param string|null $destination |
||
241 | * |
||
242 | * @return string |
||
243 | */ |
||
244 | 2 | protected function getDestinationUrl($msg, SamlMessage $message, $destination) |
|
255 | |||
256 | /** |
||
257 | * @param Request $request |
||
258 | * |
||
259 | * @return array |
||
260 | */ |
||
261 | 2 | protected function parseQuery(Request $request) |
|
290 | |||
291 | /** |
||
292 | * @param string $queryString |
||
293 | * @param bool $urlDecodeValues |
||
294 | * |
||
295 | * @return array |
||
296 | */ |
||
297 | 2 | protected function parseQueryString($queryString, $urlDecodeValues = false) |
|
310 | } |
||
311 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: