Skip to content

Commit

Permalink
Remove some old Guzzle references.
Browse files Browse the repository at this point in the history
Omnipay 3.x is now PSR-7 for responses and Symfony for
server requests.
  • Loading branch information
judgej committed Aug 23, 2018
1 parent 99cbaae commit 3ff44d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
31 changes: 10 additions & 21 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

use Symfony\Component\HttpFoundation\Request;
use Guzzle\Http\Message\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SimpleXMLElement;
Expand All @@ -20,30 +19,25 @@ class Helper
* as XML in a header line or XML in the request body.
* All of these methods are used in various places.
* XML data is parsed into a flat array.
* Supports Guzzle sewrver request/response, but be
* switched to PSR-7 messages in Omnipay 3.x versions.
*
* @param Request|Response|TBC $httpMessage a Guzzle HTTP server request or HTTP response, or a PSR-7 message (TODO)
* @param Request|ResponseInterface $httpMessage a HTTP server request or a PSR-7 message
* @return array the data as a flat array
*/
public static function extractMessageData($httpMessage)
{
// Guzzle 3 Response or PSR-7 response.
// The assumption for now is that it will always be XML.
// The assumption for now is that a syncronous response will always be XML.

if ($httpMessage instanceof Response || $httpMessage instanceof ResponseInterface) {
if ($httpMessage instanceof ResponseInterface) {
$xmlString = (string)$httpMessage->getBody();

$xmlString = simplexml_load_string($xmlString);
return static::parseXmlElement($xmlString);
}

// Guzzle 3 ServerRequest.
// CHECKME: when coult this also be a ServerRequestInterface?
// Incoming server request.
// The results could be sent by GET or POST. It's an account
// option, or an overriding request option.
// Could also be XML in a header or the body.
// Could also be XML in a header field or the body.

if ($httpMessage instanceof Request) {
if (static::getMethod($httpMessage) === 'POST') {
Expand All @@ -70,21 +64,16 @@ public static function extractMessageData($httpMessage)

// Fall back to standard GET query or POST form parameters.

return static::getFormData($httpMessage);
if (static::getMethod($httpMessage) === 'POST') {
return $httpMessage->request->all();
} else {
return $httpMessage->query->all();
}
}

return [];
}

public static function getFormData($httpMessage)
{
if (static::getMethod($httpMessage) === 'POST') {
return $httpMessage->request->all();
} else {
return $httpMessage->query->all();
}
}

public static function getMethod($httpMessage)
{
return strtoupper($httpMessage->getMethod());
Expand Down
6 changes: 3 additions & 3 deletions src/Message/AbstractNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use Omnipay\Common\Helper;
use Symfony\Component\HttpFoundation\ParameterBag;
use Guzzle\Http\ClientInterface;
use Omnipay\Common\Http\ClientInterface;
use Symfony\Component\HttpFoundation\Request as HttpRequest;

abstract class AbstractNotification implements NotificationInterface
Expand All @@ -31,7 +31,7 @@ abstract class AbstractNotification implements NotificationInterface
/**
* The request client.
*
* @var \Guzzle\Http\ClientInterface
* @var \Omnipay\Common\Http\ClientInterface
*/
protected $httpClient;

Expand All @@ -45,7 +45,7 @@ abstract class AbstractNotification implements NotificationInterface
/**
* Create a new Request
*
* @param ClientInterface $httpClient A Guzzle client to make API calls with
* @param ClientInterface $httpClient A client to make API calls with
* @param HttpRequest $httpRequest A Symfony HTTP request object
*/
public function __construct(ClientInterface $httpClient, HttpRequest $httpRequest)
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/HasCompleteResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getCardReference()
/**
* Virtual card number for MFGroup Checkout
*/
public function getVirtualCardno()
public function getVirtualCardno2()
{
return $this->getDataItem('virtualCardno');
}
Expand Down

0 comments on commit 3ff44d4

Please sign in to comment.