-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from marcvdm/fix/quote
Add quote response to the appropriate methods
- Loading branch information
Showing
17 changed files
with
386 additions
and
86 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
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,28 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace SandwaveIo\RealtimeRegister\Domain; | ||
|
||
final class DomainQuote implements DomainObjectInterface | ||
{ | ||
public function __construct( | ||
public readonly string $command, | ||
public readonly Quote $quote, | ||
) { | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'command' => $this->command, | ||
'quote' => $this->quote->toArray(), | ||
]; | ||
} | ||
|
||
public static function fromArray(array $json): DomainQuote | ||
{ | ||
return new DomainQuote( | ||
command: $json['command'], | ||
quote: Quote::fromArray($json['quote']) | ||
); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace SandwaveIo\RealtimeRegister\Domain; | ||
|
||
final class Quote implements DomainObjectInterface | ||
{ | ||
public function __construct( | ||
public readonly string $currency, | ||
public readonly int $total, | ||
public readonly BillableCollection $billables | ||
) { | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'currency' => $this->currency, | ||
'total' => $this->total, | ||
'billables' => $this->billables->toArray(), | ||
]; | ||
} | ||
|
||
public static function fromArray(array $json): Quote | ||
{ | ||
return new Quote( | ||
currency: $json['currency'], | ||
total: $json['total'], | ||
billables: BillableCollection::fromArray($json['billables']) | ||
); | ||
} | ||
} |
Oops, something went wrong.