Skip to content

Commit 7d2720f

Browse files
authored
Merge pull request #67 from academe/misc-fixes
Misc fixes
2 parents 6027cfb + 5e4083f commit 7d2720f

File tree

10 files changed

+31
-19
lines changed

10 files changed

+31
-19
lines changed

src/Helper.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
* Contains base methods that all messages will use.
66
*/
77

8+
use Closure;
9+
use DateTime;
810
use Exception;
11+
use DateTimeZone;
12+
913
use UnexpectedValueException;
1014
use Psr\Http\Message\MessageInterface;
1115
use Psr\Http\Message\ServerRequestInterface;
1216

13-
use DateTime;
14-
use DateTimeZone;
15-
1617
abstract class Helper
1718
{
1819
// SagePay date format, ISO 8601 with microseconds.

src/Request/AbstractRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Academe\SagePay\Psr7\Factory\FactoryInterface;
1414
use Academe\SagePay\Psr7\Factory\DiactorosFactory;
1515
use Academe\SagePay\Psr7\Factory\GuzzleFactory;
16+
use Academe\SagePay\Psr7\Factory\RequestFactoryInterface;
1617
use UnexpectedValueException;
1718
use JsonSerializable;
1819
use Exception;
@@ -179,7 +180,7 @@ protected function setFactory(RequestFactoryInterface $factory)
179180
protected function withFactory(RequestFactoryInterface $factory)
180181
{
181182
$clone = clone $this;
182-
return $clone->setAuth($factory);
183+
return $clone->setFactory($factory);
183184
}
184185

185186
/**

src/Request/CreatePayment.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Academe\SagePay\Psr7\Model\Auth;
1313
use Academe\SagePay\Psr7\PaymentMethod\PaymentMethodInterface;
1414
use Academe\SagePay\Psr7\Money\AmountInterface;
15+
use Academe\SagePay\Psr7\Request\Model\AddressInterface;
16+
use Academe\SagePay\Psr7\Request\Model\PersonInterface;
1517

1618
class CreatePayment extends AbstractRequest
1719
{
@@ -263,21 +265,19 @@ public static function getApply3DSecures()
263265
}
264266

265267
/**
266-
* @param ShippingAddress $shippingAddress
267-
* @return Transaction
268+
* @return self clone
268269
*/
269-
public function withShippingAddress(ShippingAddress $shippingAddress)
270+
public function withShippingAddress(AddressInterface $shippingAddress)
270271
{
271272
$copy = clone $this;
272273
$copy->shippingAddress = $shippingAddress;
273274
return $copy;
274275
}
275276

276277
/**
277-
* @param ShippingRecipient $shippingRecipient
278-
* @return Transaction
278+
* @return self clone
279279
*/
280-
public function withShippingRecipient(ShippingRecipient $shippingRecipient)
280+
public function withShippingRecipient(PersonInterface $shippingRecipient)
281281
{
282282
$copy = clone $this;
283283
$copy->shippingRecipient = $shippingRecipient;

src/Request/CreateRepeatPayment.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
use Academe\SagePay\Psr7\Model\Endpoint;
1313
use Academe\SagePay\Psr7\Model\Auth;
1414
use Academe\SagePay\Psr7\Money\AmountInterface;
15-
use Academe\SagePay\Psr7\Model\AddressInterface;
1615
use Academe\SagePay\Psr7\Model\PersonInterface;
16+
use Academe\SagePay\Psr7\Request\Model\AddressInterface;
17+
use Academe\SagePay\Psr7\Request\Model\PersonInterface as ModelPersonInterface;
1718

1819
class CreateRepeatPayment extends AbstractRequest
1920
{
@@ -29,6 +30,7 @@ class CreateRepeatPayment extends AbstractRequest
2930
// Optional or overridable data.
3031
protected $shippingAddress;
3132
protected $shippingRecipient;
33+
protected $giftAid;
3234

3335
/**
3436
* @var string The prefix is added to the name fields when sending to Sage Pay
@@ -87,7 +89,7 @@ public function __construct(
8789
* @param ShippingAddress $shippingAddress
8890
* @return Transaction
8991
*/
90-
public function withShippingAddress(ShippingAddress $shippingAddress)
92+
public function withShippingAddress(AddressInterface $shippingAddress)
9193
{
9294
$copy = clone $this;
9395
$copy->shippingAddress = $shippingAddress;
@@ -98,7 +100,7 @@ public function withShippingAddress(ShippingAddress $shippingAddress)
98100
* @param ShippingRecipient $shippingRecipient
99101
* @return Repeat
100102
*/
101-
public function withShippingRecipient(ShippingRecipient $shippingRecipient)
103+
public function withShippingRecipient(ModelPersonInterface $shippingRecipient)
102104
{
103105
$copy = clone $this;
104106
$copy->shippingRecipient = $shippingRecipient;

src/Request/FetchInstructions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ class FetchInstructions extends AbstractInstruction
1818
#[\ReturnTypeWillChange]
1919
public function jsonSerialize()
2020
{
21+
return [];
2122
}
2223
}

src/Response/AbstractCollection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
namespace Academe\SagePay\Psr7\Response;
44

5+
use ArrayIterator;
6+
use IteratorAggregate;
7+
58
/**
69
* A a collection of instructions.
710
*/
811

9-
abstract class AbstractCollection extends AbstractResponse implements \IteratorAggregate
12+
abstract class AbstractCollection extends AbstractResponse implements IteratorAggregate
1013
{
1114
/**
1215
* The list of items.
@@ -22,6 +25,7 @@ abstract class AbstractCollection extends AbstractResponse implements \IteratorA
2225
/**
2326
* @return ArrayIterator
2427
*/
28+
#[\ReturnTypeWillChange]
2529
public function getIterator()
2630
{
2731
return new ArrayIterator($this->items);

src/Response/AbstractResponse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ abstract class AbstractResponse extends AbstractMessage implements Http, RFC4918
2424
*/
2525
protected $httpCode;
2626

27+
protected $status;
28+
2729
/**
2830
* Can initialise with a PSR7 message, an array, a value object or a JSON string.
2931
*

src/Response/InstructionCollection.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ class InstructionCollection extends AbstractCollection
1616
*/
1717
protected $permittedClass = AbstractInstruction::class;
1818

19-
/**
20-
*
21-
*/
2219
public function setData($data, $httpCode = null)
2320
{
2421
if ($httpCode) {
@@ -37,6 +34,8 @@ public function setData($data, $httpCode = null)
3734
$this->add(ResponseFactory::fromData($instruction, $httpCode));
3835
}
3936
}
37+
38+
return $this;
4039
}
4140

4241
/**

src/Response/NoContent.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
class NoContent extends AbstractResponse
1212
{
1313
/**
14-
* No data to set (this is an empty messgae body).
14+
* No data to set (this is an empty message body).
15+
* @inheritDoc
1516
*/
1617
public function setData($data)
1718
{
19+
return $this;
1820
}
1921

2022
/**

src/Response/SessionKey.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function isValid()
8181
}
8282

8383
// Do we have a 404 HTTP response code recorded?
84-
if ($this->getHttpCode() !== null && $this->getHttpCode() === $this::NOT_FOUND) {
84+
if ($this->getHttpCode() !== null && $this->getHttpCode() === static::NOT_FOUND) {
8585
return false;
8686
}
8787

0 commit comments

Comments
 (0)