Skip to content

Commit 426befd

Browse files
committed
Add some more documentation
1 parent e4c54a3 commit 426befd

13 files changed

+1122
-8
lines changed

src/Omnipay/Common/AbstractGateway.php

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@
1717
* throughout the Omnipay system. It enforces implementation of
1818
* the GatewayInterface interface and defines various common attibutes
1919
* and methods that all gateways should have.
20+
*
21+
* Example:
22+
*
23+
* <code>
24+
* // Initialise the gateway
25+
* $gateway->initialize(...);
26+
*
27+
* // Get the gateway parameters.
28+
* $parameters = $gateway->getParameters();
29+
*
30+
* // Create a credit card object
31+
* $card = new CreditCard(...);
32+
*
33+
* // Do an authorisation transaction on the gateway
34+
* if ($gateway->supportsAuthorize()) {
35+
* $gateway->authorize(...);
36+
* } else {
37+
* throw new \Exception('Gateway does not support authorize()');
38+
* }
39+
* </code>
40+
*
41+
* For further code examples see the *omnipay-example* repository on github.
42+
*
43+
* @see GatewayInterface
2044
*/
2145
abstract class AbstractGateway implements GatewayInterface
2246
{
@@ -214,7 +238,30 @@ public function supportsUpdateCard()
214238
}
215239

216240
/**
217-
* Create and initialize a request object using existing parameters from this gateway
241+
* Create and initialize a request object
242+
*
243+
* This function is usually used to create objects of type
244+
* Omnipay\Common\Message\AbstractRequest (or a non-abstract subclass of it)
245+
* and initialise them with using existing parameters from this gateway.
246+
*
247+
* Example:
248+
*
249+
* <code>
250+
* class myRequest extends \Omnipay\Common\Message\AbstractRequest {};
251+
*
252+
* class myGateway extends \Omnipay\Common\AbstractGateway {
253+
* function myRequest($parameters) {
254+
* $this->createRequest('myRequest', $parameters);
255+
* }
256+
* }
257+
*
258+
* $myRequest = myGateway->myRequest($someParameters);
259+
* </code>
260+
*
261+
* @see \Omnipay\Common\Message\AbstractRequest
262+
* @param string $class The request class name
263+
* @param array $parameters
264+
* @return \Omnipay\Common\Message\AbstractRequest
218265
*/
219266
protected function createRequest($class, array $parameters)
220267
{
@@ -223,6 +270,11 @@ protected function createRequest($class, array $parameters)
223270
return $obj->initialize(array_replace($this->getParameters(), $parameters));
224271
}
225272

273+
/**
274+
* Get the global default HTTP client.
275+
*
276+
* @return HttpClient
277+
*/
226278
protected function getDefaultHttpClient()
227279
{
228280
return new HttpClient(
@@ -233,6 +285,11 @@ protected function getDefaultHttpClient()
233285
);
234286
}
235287

288+
/**
289+
* Get the global default HTTP request.
290+
*
291+
* @return HttpRequest
292+
*/
236293
protected function getDefaultHttpRequest()
237294
{
238295
return HttpRequest::createFromGlobals();

0 commit comments

Comments
 (0)