Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new util.address.ObjectOf #6

Merged
merged 4 commits into from
Oct 24, 2021
Merged

Add new util.address.ObjectOf #6

merged 4 commits into from
Oct 24, 2021

Conversation

thekid
Copy link
Member

@thekid thekid commented Oct 24, 2021

This class can replace util.address.CreationOf which only works in conjunction with the WithCreation trait. The ObjectOf definition instead creates instances of the given type (without invoking their constructor) and directly sets member variables.

Refactoring is easy:

-use util\address\CreationOf;
+use util\address\ObjectOf; 

 $address= new XmlString('<book>Name</book>');
-$book= $address->next(new CreationOf(Book::with(), [
+$book= $address->next(new ObjectOf(Book::class, [
   '.' => function($iteration) { $this->name= $iteration->next(); }
 ]));

Also, the util.address.WithCreation trait can be removed from the Book class.

This class can replace util.address.CreationOf which only works in
conjunction with the `WithCreation` trait. The ObjectOf definition
instead creates instances of the given type (without invoking their
constructor) and directly sets member variables
@thekid thekid merged commit 4dd07e8 into master Oct 24, 2021
@thekid thekid deleted the feature/object-of branch October 24, 2021 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant