-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Lunar transactions to use payment checks DTO (#1767)
- Loading branch information
1 parent
631dedc
commit fe6108a
Showing
10 changed files
with
441 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/core/src/Base/DataTransferObjects/PaymentCheck.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Lunar\Base\DataTransferObjects; | ||
|
||
class PaymentCheck | ||
{ | ||
public function __construct( | ||
public bool $successful, | ||
public string $label, | ||
public string $message | ||
) { | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
packages/core/src/Base/DataTransferObjects/PaymentChecks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Lunar\Base\DataTransferObjects; | ||
|
||
class PaymentChecks implements \ArrayAccess, \Iterator | ||
{ | ||
private int $position = 0; | ||
|
||
protected array $checks = []; | ||
|
||
public function addCheck(PaymentCheck $check): void | ||
{ | ||
$this->checks[] = $check; | ||
} | ||
|
||
public function getChecks(): array | ||
{ | ||
return $this->checks; | ||
} | ||
|
||
public function current(): PaymentCheck | ||
{ | ||
return $this->checks[$this->position]; | ||
} | ||
|
||
public function next(): void | ||
{ | ||
$this->position++; | ||
} | ||
|
||
public function key(): mixed | ||
{ | ||
return $this->position; | ||
} | ||
|
||
public function valid(): bool | ||
{ | ||
return isset($this->checks[$this->position]); | ||
} | ||
|
||
public function rewind(): void | ||
{ | ||
$this->position = 0; | ||
} | ||
|
||
public function offsetExists(mixed $offset): bool | ||
{ | ||
return isset($this->checks[$offset]); | ||
} | ||
|
||
public function offsetGet(mixed $offset): mixed | ||
{ | ||
return $this->checks[$offset]; | ||
} | ||
|
||
public function offsetSet(mixed $offset, mixed $value): void | ||
{ | ||
if (is_null($offset)) { | ||
$this->checks[] = $value; | ||
} else { | ||
$this->checks[$offset] = $value; | ||
} | ||
} | ||
|
||
public function offsetUnset(mixed $offset): void | ||
{ | ||
unset($this->checks[$offset]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.