18
18
use Omnipay \Common \Http \Client ;
19
19
use Omnipay \Common \Http \ClientInterface ;
20
20
use Omnipay \Common \ItemBag ;
21
+ use Omnipay \Common \ParametersTrait ;
21
22
use Symfony \Component \HttpFoundation \ParameterBag ;
22
23
use Symfony \Component \HttpFoundation \Request as HttpRequest ;
23
24
66
67
*/
67
68
abstract class AbstractRequest implements RequestInterface
68
69
{
69
- /**
70
- * The request parameters
71
- *
72
- * @var \Symfony\Component\HttpFoundation\ParameterBag
73
- */
74
- protected $ parameters ;
70
+ use ParametersTrait {
71
+ setParameter as traitSetParameter;
72
+ }
75
73
76
74
/**
77
75
* The request client.
@@ -145,27 +143,6 @@ public function initialize(array $parameters = array())
145
143
return $ this ;
146
144
}
147
145
148
- /**
149
- * Get all parameters as an associative array.
150
- *
151
- * @return array
152
- */
153
- public function getParameters ()
154
- {
155
- return $ this ->parameters ->all ();
156
- }
157
-
158
- /**
159
- * Get a single parameter.
160
- *
161
- * @param string $key The parameter key
162
- * @return mixed
163
- */
164
- protected function getParameter ($ key )
165
- {
166
- return $ this ->parameters ->get ($ key );
167
- }
168
-
169
146
/**
170
147
* Set a single parameter
171
148
*
@@ -180,9 +157,7 @@ protected function setParameter($key, $value)
180
157
throw new RuntimeException ('Request cannot be modified after it has been sent! ' );
181
158
}
182
159
183
- $ this ->parameters ->set ($ key , $ value );
184
-
185
- return $ this ;
160
+ return $ this ->traitSetParameter ($ key , $ value );
186
161
}
187
162
188
163
/**
@@ -206,25 +181,6 @@ public function setTestMode($value)
206
181
return $ this ->setParameter ('testMode ' , $ value );
207
182
}
208
183
209
- /**
210
- * Validate the request.
211
- *
212
- * This method is called internally by gateways to avoid wasting time with an API call
213
- * when the request is clearly invalid.
214
- *
215
- * @param string ... a variable length list of required parameters
216
- * @throws InvalidRequestException
217
- */
218
- public function validate ()
219
- {
220
- foreach (func_get_args () as $ key ) {
221
- $ value = $ this ->parameters ->get ($ key );
222
- if (! isset ($ value )) {
223
- throw new InvalidRequestException ("The $ key parameter is required " );
224
- }
225
- }
226
- }
227
-
228
184
/**
229
185
* Get the card.
230
186
*
0 commit comments