1818use Omnipay \Common \Http \Client ;
1919use Omnipay \Common \Http \ClientInterface ;
2020use Omnipay \Common \ItemBag ;
21+ use Omnipay \Common \ParametersTrait ;
2122use Symfony \Component \HttpFoundation \ParameterBag ;
2223use Symfony \Component \HttpFoundation \Request as HttpRequest ;
2324
6667 */
6768abstract class AbstractRequest implements RequestInterface
6869{
69- /**
70- * The request parameters
71- *
72- * @var \Symfony\Component\HttpFoundation\ParameterBag
73- */
74- protected $ parameters ;
70+ use ParametersTrait {
71+ setParameter as traitSetParameter;
72+ }
7573
7674 /**
7775 * The request client.
@@ -145,27 +143,6 @@ public function initialize(array $parameters = array())
145143 return $ this ;
146144 }
147145
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-
169146 /**
170147 * Set a single parameter
171148 *
@@ -180,9 +157,7 @@ protected function setParameter($key, $value)
180157 throw new RuntimeException ('Request cannot be modified after it has been sent! ' );
181158 }
182159
183- $ this ->parameters ->set ($ key , $ value );
184-
185- return $ this ;
160+ return $ this ->traitSetParameter ($ key , $ value );
186161 }
187162
188163 /**
@@ -206,25 +181,6 @@ public function setTestMode($value)
206181 return $ this ->setParameter ('testMode ' , $ value );
207182 }
208183
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-
228184 /**
229185 * Get the card.
230186 *
0 commit comments