-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove redundant $toClass from MicroMapper, allowing improv…
…ement of generic templating
- Loading branch information
Showing
5 changed files
with
22 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ | |
* Also add #[AsMapper(from: Foo:class, to: Bar:class)] to each mapper class. | ||
* | ||
* @author Ryan Weaver <[email protected]> | ||
* | ||
* @template TFrom of object | ||
* @template TTo of object | ||
*/ | ||
interface MapperInterface | ||
{ | ||
|
@@ -24,22 +27,21 @@ interface MapperInterface | |
* This method should load (e.g. from the database) or instantiate the "to object". | ||
* Avoid populating any properties except for an identifier. | ||
* | ||
* @template TTo of object | ||
* | ||
* @param class-string<TTo> $toClass | ||
* @param TFrom $from | ||
* @param array<mixed> $context | ||
* | ||
* @return TTo | ||
*/ | ||
public function load(object $from, string $toClass, array $context): object; | ||
public function load(object $from, array $context): object; | ||
|
||
/** | ||
* Populate the data onto the "to object" from the "from object". | ||
* | ||
* Receives the "to object" returned from load(). | ||
* | ||
* @template TTo of object | ||
* | ||
* @param TTo $to | ||
* @param TFrom $from | ||
* @param TTo $to | ||
* @param array<mixed> $context | ||
* | ||
* @return TTo | ||
*/ | ||
|
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