Skip to content

Commit

Permalink
Added hasItems and getItems methods to the Payable interface
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Apr 25, 2024
1 parent bb8b530 commit 553cc3a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
- `getPayableRemoteId()`
- `setPayableRemoteId()`
- `findByPayableRemoteId()`
- `hasItems()`
- `getItems()`
- BC: The return type of the `getNumber()` method of the Order interface is no longer nullable
- BC: Added the `getCalculator()` & `estimate()` methods to the `ShippingMethod` interface
- BC: The `Channel` interface extends the `Configurable` interface
Expand Down
2 changes: 2 additions & 0 deletions src/Contracts/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- `getPayableRemoteId()`
- `setPayableRemoteId()`
- `findByPayableRemoteId()`
- `hasItems()`
- `getItems()`
- Added the nette/schema package requirement (v1.2.5+)

## 3.x Series
Expand Down
6 changes: 6 additions & 0 deletions src/Contracts/Payable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Vanilo\Contracts;

use Traversable;

interface Payable
{
public function getPayableId(): string;
Expand All @@ -34,6 +36,10 @@ public function setPayableRemoteId(string $remoteId): void;

public static function findByPayableRemoteId(string $remoteId): ?Payable;

public function hasItems(): bool;

public function getItems(): Traversable;

/** The human readable representation, eg.: "Order no. ABC-123" */
public function getTitle(): string;
}
5 changes: 5 additions & 0 deletions src/Order/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public function getLanguage(): ?string
return $this->language;
}

public function hasItems(): bool
{
return $this->items->isNotEmpty();
}

public function getItems(): Traversable
{
return $this->items;
Expand Down
13 changes: 13 additions & 0 deletions src/Payment/Tests/Examples/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

namespace Vanilo\Payment\Tests\Examples;

use ArrayIterator;
use Illuminate\Database\Eloquent\Model;
use Traversable;
use Vanilo\Contracts\Billpayer;
use Vanilo\Contracts\Payable;

Expand Down Expand Up @@ -52,6 +54,17 @@ public function getBillpayer(): ?Billpayer
return new Customer();
}

public function hasItems(): bool
{
return false;
}

public function getItems(): Traversable
{
return new ArrayIterator([]);
}


public function getNumber(): string
{
return (string) $this->id;
Expand Down

0 comments on commit 553cc3a

Please sign in to comment.